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 |
How should I destroy my objects in asp.net?
What is a transaction? a) A banking term. b) A concept used to describe a step in the business process. c) A combination of DML steps that must succeed or the data is retuned to its initial state. d) A combination of DDL steps that must succeed or the data is retuned to its initial state.
witch is the best insistute in sharpoint course.what abt future of share point course.
Explain automatic memory management in .net.
Can you edit data in the Repeater control? Which template must you provide, in order to display data in a Repeater control? How can you provide an alternating color scheme in a Repeater control? What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
Which class provides methods that can be used to manage role membership to be used in user authorization?
What is web application virtual directory ?
What is difference between datalist and gridview?
Any body Having SHAREPOINT Material plzzz? please material to send prasad.k12@gmail.com
Explain server control extensibility with reference to asp.net 2.0 ?
What is the use of @Register directives?
why should i use FormsAuthentication.RedirectFromLoginPage (); Method in Form Authentication?Without using this method also it's good??