Help with syntax
-
Dim sqlConnection1 As New System.Data.SqlClient.SqlConnection("Data Source=MUSCRIBMPC\SQLEXPRESS;Initial Catalog=adp3SQL;Integrated Security=True") Dim fname, lname As String fname = TextBox2.Text lname = textbox2.text Dim cmd As New System.Data.SqlClient.SqlCommand cmd.CommandType = System.Data.CommandType.Text cmd.CommandText = "update compiledpts set firstname=fname, lastname=lname where contactid = 2" cmd.Connection = sqlConnection1 sqlConnection1.Open() cmd.ExecuteNonQuery() sqlConnection1.Close() contactid is the table ID, compiledpts is the name of the table. everything else works except the syntax in the commandtext. if firstname is = " anytext " it updates with that text but I cannot use fname and I cannot use more than one viriable. WHAT IS WRONG PLEASE?
-
Dim sqlConnection1 As New System.Data.SqlClient.SqlConnection("Data Source=MUSCRIBMPC\SQLEXPRESS;Initial Catalog=adp3SQL;Integrated Security=True") Dim fname, lname As String fname = TextBox2.Text lname = textbox2.text Dim cmd As New System.Data.SqlClient.SqlCommand cmd.CommandType = System.Data.CommandType.Text cmd.CommandText = "update compiledpts set firstname=fname, lastname=lname where contactid = 2" cmd.Connection = sqlConnection1 sqlConnection1.Open() cmd.ExecuteNonQuery() sqlConnection1.Close() contactid is the table ID, compiledpts is the name of the table. everything else works except the syntax in the commandtext. if firstname is = " anytext " it updates with that text but I cannot use fname and I cannot use more than one viriable. WHAT IS WRONG PLEASE?
The syntax would be.... "update compiledpts set firstname='" & fname & "', lastname='" & lname & "' where contactid = 2"
Tirtha Do not go where the path may lead, go instead where there is no path and leave a trail. Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist
-
The syntax would be.... "update compiledpts set firstname='" & fname & "', lastname='" & lname & "' where contactid = 2"
Tirtha Do not go where the path may lead, go instead where there is no path and leave a trail. Author: Ralph Waldo Emerson (1803-82), American writer, philosopher, poet, essayist