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 is virtual directory in asp.net?

0 Answers  


About delegates ?

7 Answers   TCS,


What is autopostback in asp net?

0 Answers  


Take a Large textbox allow to type any data. Task 1:display the count of vowels in a lable on key press event of the textbox Task 2:dispaly count of dates in a lable when dates in following foramats:dd/mm/yy , mm/dd/yy , yy/mm/dd. Task3:compare 2 dates and display both are same or not which dates are in dd/mm/yy and mm/dd/yy farmats.

0 Answers   eMids,


Where would you use an IHttpModule, and what are the limitations of anyapproach you might take in implementing one?

1 Answers   Siebel Systems,






I have around 200+ controls in a page. Each of the sets of controls are kept in divs and when header div is clicked, only those div controls pertaining to that header div will be displayed. Rest of the divs are kept invisible. When the page loads, all these 200+ controls are loaded simultaneously, that consumes much of the time. What my requirement is I want to get the div1 controls loaded when the page loads and rest of the div controls should be loaded asynchronously. it should not be loaded with page load, so that time for loading the page can be much minimised. Hope u understood my question and pls help me out with a solution asap....

2 Answers  


What is the use of asp.net web api?

0 Answers  


What is the difference between union and structure?

0 Answers  


What is full form of asp.net?

0 Answers  


We are using Jscriopt validations and at clint site javascript is not running that time validation would work? if yes then how it would behave?

0 Answers  


Explain significance of routing? : asp.net mvc

0 Answers  


How do session tokens work?

0 Answers  


Categories