Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExecuteNonQuery() error

Status
Not open for further replies.

magmo

Programmer
May 26, 2004
291
SE
Hi

I try to use this code in a vb.net application but I get a an error on the "MyCommand.ExecuteNonQuery()" line.
I dont see any faults in this code, am I missing something here?

Code:
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim MyDataReader As SqlDataReader
MyConnection = New SqlConnection(connStr)
MyCommand = New SqlCommand("p_DropColumn", MyConnection)
MyCommand.CommandType = CommandType.StoredProcedure
MyConnection.Open()
MyCommand.ExecuteNonQuery()
MyConnection.Dispose()

The only errror message VS give me is...

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.


(The stored procedure is to drop a column in a database table.)


Regards
 
if you try it without using the sp for example alter table drop column does it work then?

is your connectionstring aimed for the correct database?

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Hi


Just found out that I do not have permissions to drop a column in the database table.


Regards
 
yep, that could be it.

placing the executenonquery in a try catch would have probably told you that.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top