Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB
sqlquery = "insert into StudentMaster(Studentname,fathername,address1,address2,City,Pincode,standard,section,fees,joining,stream,phone) Values (TextBox1.Text,'" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "',"
        '" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "',TextBox10.Text,
        '" + TextBox11.Text + "','" + TextBox12.Text + "','" + TextBox13.Text + "')"
        Try
Posted

1 solution

As I told you 15 minutes ago: ID IS bigint. while compiling it is showing some problem in textbox1.text[^] do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

An example would be:
VB
Using con As New SqlConnection(strConnect)
    con.Open()
    Using com As New SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con)
        com.Parameters.AddWithValue("@C1", myValueForColumn1)
        com.Parameters.AddWithValue("@C2", myValueForColumn2)
        com.ExecuteNonQuery()
    End Using
End Using
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900