Another SQL Query issue that i am having. If anyone could help it would be appreciated.
No errors are thrown (using the Try syntax) however it is not updating the database.
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='\\$$$$\$$$$\$$$$.accdb';")
Dim str As String
str = "update Layer_1 set 1=@1, 2=@2, 3=@3, 4=@4, 5=@5, 6=@6, 7=@7, 8=@8, 9=@9, 10=@10 where ID=@id"
Dim cmd As New OleDbCommand(str, con)
cmd.Parameters.AddWithValue("@1", val2.Text)
cmd.Parameters.AddWithValue("@2", val3.Text)
cmd.Parameters.AddWithValue("@3", val4.Text)
cmd.Parameters.AddWithValue("@4", val5.Text)
cmd.Parameters.AddWithValue("@5", val6.Text)
cmd.Parameters.AddWithValue("@6", val7.Text)
cmd.Parameters.AddWithValue("@7", val8.Text)
cmd.Parameters.AddWithValue("@8", val9.Text)
cmd.Parameters.AddWithValue("@9", val10.Text)
cmd.Parameters.AddWithValue("@10", val11.Text)
cmd.Parameters.AddWithValue("@ID", SysID.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
So the Val[#].Text is a textbox, whilst the SysId is a label,
I also have each Param written in the following Syntax, just to see if there is a problem with my code. But its the same output, no DB update but no errors.
I do have a smaller variation of this codes which works but i am not sure why, as it is an exact copy with more expressions added in.
Dim str As String
str = "update FDSL set Hostname=@Hostname, Owner=@Owner where ID=@id"
Dim cmd As New OleDbCommand(str, con)
cmd.Parameters.AddWithValue("@Hostname", TextBox1.Text)
cmd.Parameters.AddWithValue("@Owner", TextBox2.Text)
cmd.Parameters.AddWithValue("@ID", textbox6.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Any Ideas?
Cheers, Tad