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 (1443)
 VB.NET interview questions  VB.NET Interview Questions (150)
 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 (33)
 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 ?    186 Yes 80 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 ?    156 Yes 54 No
V.vijayakumar
 
 
 
Answer
# 3
insert into emp(empname) values('"+textbox1.Text+"'); 
Is This Answer Correct ?    156 Yes 60 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 55 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 ?    110 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 ?    48 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 transpose rows into columns and columns into rows in a multi-dimensional array ? Microsoft 1
Types of store procedure in Sqlserver?   3
What does assemblyinfo.cs file consist of? Accenture 2
What is the Difference B/W Finalize() and Dispose() in .Net? HCL 12
if u r projet consist of 4 people means how can u manage the file Mind-Tree 10
What line in the following XML document will generate an error? <?xml version=?1.0?> <employees> <employee> <name>Bob Andcarrol</name> </employee> <employee> <name>Robert Burns</name> </employee> </employees> a) 6 b) 4 c) 1 d) There is no error Syntax-Softtech 3
What?s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"? SLC-Ltd 5
what is asp.net   4
What methods are fired during the page load?   1
Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.   1
Usage of web.config? Microsoft 2
4. How do you plan to achieve these goals? Swatz-Oils 3
 
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