How to Insert a TextBox value in to Sql database using C#
coding?
Answers were Sorted based on User's Feedback
Answer / anand
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source=anand\\sqlexpress.
initial catalog=Database1;integrated security=sspi;";
SqlCommand myCommand = new SqlCommand();
myCommand.CommandText = "Insert into
usr(firstname,lastname,dob,phno,email,Address,state,bgroup)
Values('" + firstname.Text + "','" + lastname.Text + "'," +
dob.Text + "," + phno.Text + ",'" + email.Text + "','" +
Address.Text + "','" + state.Text + "','" + bgroup.Text + "')";
myCommand.Connection = con;
con.Open();
myCommand.ExecuteNonQuery();
con.Close();
| Is This Answer Correct ? | 5 Yes | 4 No |
Answer / balakumar
string strconn = @"Data Source=localhost;
Initial Catalog=Bala;
Trusted_Connection=yes;";
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
string insertcommand = "insert into Employee
values('" + TextBox1.Text + "','" + TextBox2.Text + "','" +
TextBox3.Text + "')";
SqlCommand cmd = new SqlCommand(insertcommand, conn);
cmd.ExecuteNonQuery();
conn.Close();
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / surendra
How to Insert two TextBoxs values in to one column sql database using C# coding
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mmm
almost all the posted answers above are correct(85%).
| Is This Answer Correct ? | 3 Yes | 4 No |
Answer / jeevananth
try
{
SqlConnecion cn=new SqlConnection("Data
source=.;database=Studentdetail;uid=sa;pwd=sa");
SqlCommand cmd=new SqlCommand();
cn.Open();
string qry;
qry="insert into Table values('"+ TextBox1.Text +"','"+
TextBox2.Text +"')";
cmd=new(qry,cn);
cmd.cmd.ExecuteNonQuery();
cn.Close();
}
catch(Exception ex)
{
Responce.Write(ex.Message.ToString());
}
| Is This Answer Correct ? | 0 Yes | 6 No |
Which property needs to be set for script manager control to extend the time before throwing time out expection if no response is received from the server?
How many web.config files in each solution
Explain different types of Caching techniques in ASP.NET?
0 Answers Sans Pareil IT Services,
What is the difference between client-side and server-side validations in ASP.NET?
0 Answers Sans Pareil IT Services,
How to send auto matic emails based on scheduled tasks to several of my clients
what are Httpmodule and HttpHandler?
Define a web service in .net?
What is an asp.net web form?
What threading model used in asp and asp.net?
How can we create pie chart in asp.net?
How do you do client-side validation in .net? How to disable validator control by client side javascript?
What?s a bubbled event?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)