Command.Execute Error (ADO.NET)

I

Ivan Weiss

I am getting the following error from my error handling code:

5 - Expected query name after EXECUTE..

from the following code:

Public Sub insert(ByVal argSql As String)
Dim myConnection As New OleDbConnection(dbConnString)
Dim myCommand As New OleDbCommand()

myCommand.Connection = myConnection
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = argSql

Try
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
Catch
DisplayErrorMessage("clsDatabase:insertData")
End Try

End Sub

Any ideas??

-Ivan
 
D

David Williams

I can think of a couple of things right off that could cause that error.

1) Is the stored procedure attempting to return data?
2) The stored procedure is incorrect in that it is returning this error.

Hope these help, it is difficult to help without more information, i.e. the
text of the stored procedure and the value of argSQL.

David
 
H

Herfried K. Wagner [MVP]

* Ivan Weiss said:
I am getting the following error from my error handling code:

5 - Expected query name after EXECUTE..

from the following code:

Public Sub insert(ByVal argSql As String)
Dim myConnection As New OleDbConnection(dbConnString)
Dim myCommand As New OleDbCommand()

myCommand.Connection = myConnection
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = argSql

Try
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
Catch
DisplayErrorMessage("clsDatabase:insertData")
End Try

End Sub

Any ideas??

Group for ADO.NET questions:

<
Web interface:

<http://msdn.microsoft.com/newsgroup...roup=microsoft.public.dotnet.framework.adonet>
 
O

One Handed Man

It sounds like your sql string is invalid and that either the stored
procedure does not exist or has not been specified.

OHM
 
I

Ivan Weiss

Sorry guys it was a dumb mistake. I had the command object set to
stored procedure when I was generated the sql statement so it should
have been text.

Thanks

-Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top