ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Microsoft Related >> ASP.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions (615)
 C Sharp interview questions  C Sharp Interview Questions (722)
 ASP.NET interview questions  ASP.NET Interview Questions (1444)
 VB.NET interview questions  VB.NET Interview Questions (151)
 COM+ interview questions  COM+ Interview Questions (41)
 ADO.NET interview questions  ADO.NET Interview Questions (199)
 IIS interview questions  IIS Interview Questions (86)
 MTS interview questions  MTS Interview Questions (5)
 Crystal Reports interview questions  Crystal Reports Interview Questions (62)
 BizTalk interview questions  BizTalk Interview Questions (34)
 Dot Net interview questions  Dot Net Interview Questions (861)
 Exchange Server interview questions  Exchange Server Interview Questions (103)
 SharePoint interview questions  SharePoint Interview Questions (25)
 WCF interview questions  WCF Interview Questions (8)
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions (193)
Question
How to Insert a TextBox value in to Sql database using C#
coding?
 Question Submitted By :: ASP.NET
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
insert into emp(empname) values('"+textbox1.value+"')


If you use html cocntrol textbox1.Value
or
If you use Aso cocntrol textbox1.Text
 
Is This Answer Correct ?    188 Yes 82 No
Chandra Shaker
 
Answer
# 2
Syntax:
INSERT INTO table name(column name,column name,column
name)values(values,values,values);
Example:
INSERT INTO
employee(Name,emp_id,designation)values('"+textbox1.text+"',"+textbox2.text+",'"+textbox3.text+"');


..................if u use Html control we must use
textbox1.value ..if u use asp.net controls we have to use
textbox1.text........
 
Is This Answer Correct ?    157 Yes 54 No
V.vijayakumar
 
 
 
Answer
# 3
insert into emp(empname) values('"+textbox1.Text+"'); 
Is This Answer Correct ?    157 Yes 61 No
Sona
 
Answer
# 4
in asp.net webform,

first assign namespace like using system.data.sqlclient;

insert coding

sqlcommand cmd = new sqlcommand("insert into address values
('"+ textbox1.text +"', "+ textbox2.text +")",
connectionstring);

note:
 
Is This Answer Correct ?    143 Yes 56 No
Premkumar.m
 
Answer
# 5
SqlCommand CmdSql = new SqlCommand("INSERT INTO
Customers(FirstName,Surname,Address,City,Postcode,PhoneNumber)
Values
(@FirstName,@Surname,@Address,@City,@Postcode,@PhoneNumber)", conn);
conn.Open();
CmdSql.Parameters.AddWithValue("@FirstName", FirstName);
CmdSql.Parameters.AddWithValue("@Surname", Surname);
CmdSql.Parameters.AddWithValue("@Address", Address);
CmdSql.Parameters.AddWithValue("@City", City);
CmdSql.Parameters.AddWithValue("@Postcode", Postcode);
CmdSql.Parameters.AddWithValue("@PhoneNumber",
PhoneNumber);
CmdSql.ExecuteNonQuery();
conn.Close();

//all @values are names of the variables the text value is
stored as (you could also enter txtFirstName.Text etc.)
//conn = connection name (which should be declared before
the page_load
 
Is This Answer Correct ?    111 Yes 33 No
Digital
 
Answer
# 6
SqlConnection con = new SqlConnection();
con.ConnectionString = "connection string(path)";
try
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into emp_detail values(' " + tb1.Text + " ',' " + tb2.Text + " ',' " + tb3.Text + " ')", con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
 
Is This Answer Correct ?    62 Yes 26 No
Jegan
 
Answer
# 7
SqlConnection conn = new SqlConnection(strCon);
SqlCommand CmdSql = new SqlCommand("INSERT INTO Customers
(Firstname,Lastname,Address)Values('" + textbox1.Text
+ "', '"+textbox2.Test+"', '"+textbox3.Text+"')", conn);
CmdSql.ExecuteNonQuery();


\\If u use Html control we must use
textbox1.value
\\If u use asp.net controls we have to use
textbox1.text
 
Is This Answer Correct ?    49 Yes 23 No
Ramachandraprabu
 
Answer
# 8
sqlcommand cmd = new sqlcommand("insert into address values
(@textbox1.text,@textbox2.text)",connectionstring);
 
Is This Answer Correct ?    61 Yes 37 No
Pksutha
 
Answer
# 9
sqlcommand cmd = new sqlcommand("insert into address values
('"+ textbox1.text +"', "+ textbox2.text +")",
connectionstring);
 
Is This Answer Correct ?    64 Yes 41 No
Suthasyed
 
Answer
# 10
first assign namespace like using system.data.sqlclient;

SqlCommand cmd = new SqlCommand("insert into emp
(EmpName,EmployeeCode,Designation,Location)values('" +
TextBox1.Text + "','" + TextBox2.Text + "','" +
TextBox3.Text + "','" + TextBox4.Text + "')");
 
Is This Answer Correct ?    50 Yes 33 No
Pranitha
 

 
 
 
Other ASP.NET Interview Questions
 
  Question Asked @ Answers
 
How to write test case (Unit test plan) Syntel 1
To which class you load XML or Related Data   1
In the context of a comparison, what is object identity versus object equivalence?   1
Where do you store the information about the user?s locale?   2
what is page life cycle state management postback cross page postback types of feilds in gridview gridview events their life cycle cte in sql diff truncate and delete paging concepts in gridview diff bet gridview datalist and repeater what new operations in sql 2005 compared to earlier you get e4e 1
What is server objects in asp.net?   5
How many types of Stored Procedures in SQL Server Mind-Tree 4
Explain what a diffgram is, and a good use for one? FT 1
Code for scolling in gridview TCS 1
code for inserting images into gridview colomns from database HP 3
Which template must you provide, in order to display data in a Repeater control? Wipro 3
what is SQL cache Invalidation?   1
 
For more ASP.NET Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com