Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The label 'N' has already been declared. Label names must be unique within a query batch or stored procedure

Tags:

.net

sql

vb.net

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
like image 946
Klaas-Jelle Ras Avatar asked Oct 29 '22 09:10

Klaas-Jelle Ras


1 Answers

You have not valid Command text there i suppose.

    cmd.CommandText = "INSERT INTO opdracht (FilePath, ImageSide, ImageSize) VALUES ('"
 + TextBox1.Text + "')"
like image 142
Whencesoever Avatar answered Nov 15 '22 05:11

Whencesoever