I have a question.
I need to make a program in vb.net that needs to set text in a sql database. But everytime when I click on Export to Database the program shuts down and says:
The label 'N' has already been declared. Label names must be unique within a query batch or stored procedure
I don't know what this means, I'm new to .net languages. Hope someone can help me.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\klaasjelle\documents\visual studio 2017\Projects\Opdracht\Opdracht\Opdracht1.mdf;Integrated Security=True"
con.Open()
cmd.Connection = con
cmd.CommandText = $"INSERT INTO opdracht ('FilePath', 'ImageSide', 'ImageSize') VALUES ('{TextBox1.Text}')"
cmd.ExecuteNonQuery()
End Sub
You have not valid Command text there i suppose.
cmd.CommandText = "INSERT INTO opdracht (FilePath, ImageSide, ImageSize) VALUES ('"
+ TextBox1.Text + "')"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With