The "N" label has already been declared. Shortcut names must be unique within a query package or stored procedure

I have a question.

I need to make a program in vb.net that should set text in sql database. But every time I click "Export to Database" the program shuts down and says:

The 'N' label has already been declared. Shortcut names must be unique in batch or stored query 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

      

+3


source to share


1 answer


You have the wrong command text there, I suppose.



    cmd.CommandText = "INSERT INTO opdracht (FilePath, ImageSide, ImageSize) VALUES ('"
 + TextBox1.Text + "')"

      

+2


source







All Articles