Update allowed in SQL Server Management Studio but not in code vb.net with error ‘update not permitted’

I am writing some code to update an SQL table using a query string in vb.net.

Now when I run this query from code it comes up with the error:

Additional information: The UPDATE permission was denied on the object ‘LabelsEC00’, database ‘i_EC’, schema ‘dbo’.

However, if I then run the same query from SQL Server Management Studio; it allows me to update the table.

So surely if I did not have permissions I wouldn’t be allowed to update through sql management studio either correct?

This is the query I am using from code:

Dim query As String = "Update [i_EC].[dbo].[LabelsEC00] SET Labels = 'Yes' WHERE ConvertingLabelsID = '{5C6795D3-53EA-41F7-A757-2AEF62A000CA}'"

Dim con As New SqlConnection
    Dim cmd As New SqlCommand

    con.ConnectionString = My.Settings.ConnString

    cmd.Connection = con

    cmd.CommandText = query


If anyone could shine some light on the subject I would be grateful.


Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.