ninjaX Posted April 18, 2004 Posted April 18, 2004 i have a problem for the INSERT part. :( :( i only know how to add data into database...like: SqlCommand myCommand = new SqlCommand("Insert into employee(id, name, pass) values('1','John','aaa')", sqlConnection1); but, i don't know how to use the TextBox insert data to database. What is the codes for the VALUES part? Who know can help me??? Quote
Moderators Robby Posted April 18, 2004 Moderators Posted April 18, 2004 Assuming that the ID column is numeric you may want to get rid of the single quotes and converting the value to Int, I'm 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); Quote Visit...Bassic Software
ninjaX Posted April 18, 2004 Author Posted April 18, 2004 Assuming that the ID column is numeric you may want to get rid of the single quotes and converting the value to Int, I'm 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 Quote
ninjaX Posted April 18, 2004 Author Posted April 18, 2004 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... Quote
Moderators Robby Posted April 18, 2004 Moderators Posted April 18, 2004 In J# it's TextBox1.set_Text and .get_Text This may help http://samples.gotdotnet.com/quickstart/latebreaking/default.aspx?url=/quickstart/latebreaking/quickstartinfo.aspx?id=1081&lang=VJS Quote Visit...Bassic Software
Moderators Robby Posted April 18, 2004 Moderators Posted April 18, 2004 You need the single quotes to surround your variables Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.