How to Insert a TextBox value in to Sql database using C#
coding?

Answers were Sorted based on User's Feedback



How to Insert a TextBox value in to Sql database using C# coding?..

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

How to Insert a TextBox value in to Sql database using C# coding?..

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

How to Insert a TextBox value in to Sql database using C# coding?..

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

How to Insert a TextBox value in to Sql database using C# coding?..

Answer / thualsi

insertBox("(Text1.Text)")+("(Text1.Text)");

Is This Answer Correct ?    0 Yes 0 No

How to Insert a TextBox value in to Sql database using C# coding?..

Answer / mmm

almost all the posted answers above are correct(85%).

Is This Answer Correct ?    3 Yes 4 No

How to Insert a TextBox value in to Sql database using C# coding?..

Answer / ghanshyam verma

c# question in type

Is This Answer Correct ?    0 Yes 4 No

How to Insert a TextBox value in to Sql database using C# coding?..

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

Post New Answer

More ASP.NET Interview Questions

What are different types of directives in .NET ?

1 Answers  


Is it possible to add aspx.vb file in to C# Web Project? If so how can i use the vb file in the C# Web project?

3 Answers  


What is http only cookie?

0 Answers  


How we can force all the validation controls to run?

0 Answers  


What tags do you need to add within the asp:datagrid tags to bind columns manually?

5 Answers   Siebel Systems,






Explain the concept of MVC Scaffolding?

0 Answers   B-Ways TecnoSoft,


How can you handle exceptions in asp.net?

0 Answers  


To display data in a Repeater control which templete is provided ?

4 Answers   Siebel,


Why is xap important?

0 Answers  


How do you specify whether your data should be passed as Query string and Forms (Mainly about POST and GET)

2 Answers  


About CLS and CTS ?

3 Answers   Microsoft,


What is difference between viewstate and session state in javascript?

0 Answers  


Categories