How to insert data to database using TextBox?

ninjaX

Member
Joined
Mar 29, 2004
Messages
6
i have a problem for the INSERT part. :( :(
i only know how to add data into database...like:

Code:
		SqlCommand myCommand = new SqlCommand("Insert into employee(id, name, pass) values(1,John,aaa)", sqlConnection1);

but, i dont know how to use the TextBox insert data to database. What is the codes for the VALUES part? Who know can help me???
 
Assuming that the ID column is numeric you may want to get rid of the single quotes and converting the value to Int, Im not sure of any J# syntax....

SqlCommand myCommand = new SqlCommand("Insert into employee(id, name, pass) values(" + Convert.ToInt32(TextBoxID.Text) + "," + TextBox1.Text + "," + TextBox2.Text + ")", sqlConnection1);
 
Robby said:
Assuming that the ID column is numeric you may want to get rid of the single quotes and converting the value to Int, Im not sure of any J# syntax....

SqlCommand myCommand = new SqlCommand("Insert into employee(id, name, pass) values(" + Convert.ToInt32(TextBoxID.Text) + "," + TextBox1.Text + "," + TextBox2.Text + ")", sqlConnection1);

i think this one is use at the VB.NET one
because J# dont have .text one
 
thanks....
but i tried already still cannot add-in database.
This is my new changing codes:

SqlCommand myCommand = new SqlCommand("Insert into employee(id, name, pass) values(" + textBox1.get_Text() + "," + textBox2.get_Text() + "," + textBox3.get_Text() + ")", sqlConnection1);

who know abt the J# syntax??? can somebody help me...
 
Back
Top