Need help with calling custom Stored Proc from ASP.Net (VB.Net)

J

Jack Black

Help!! I'm trying to call a custom stored procedure from a VB.Net
code-behind page in an ASP.Net application, and I keep getting an
error with no real helpful info...

Basically, I'm accepting a username and password from a front-end, and
performing a simple INSERT into a SQL Server table via a custom stored
procedure in the database. All privileges are fine, and the stored
procedure works fine (inserts records perfectly; tested with both ASP
and SQL's QueryAnalyzer), so SQL Server can be ruled out (I think) as
part of the issue.

Here is the code I'm using:
*************************************************
Sub storeUserAccount(ByVal strUsername As String, ByVal _
strPasswordHash As String, ByVal strSaltValue As String, ByVal _
strOffice As String, ByRef objData As _
System.Data.SqlClient.SqlConnection)

Dim objCommand As New SqlClient.SqlCommand("createUserAccount",
objData)
Dim objParameter As New SqlClient.SqlParameter

objParameter = objCommand.Parameters.Add("@userName",
SqlDbType.VarChar, 50)
objParameter.Value = strUsername

objParameter = objCommand.Parameters.Add("@passwordHash",
SqlDbType.VarChar, 1024)
objParameter.Value = strPasswordHash

objCommand.ExecuteNonQuery()

end sub
**************************************************

I know the data connection (OBJDATA) is open already because I perform
other functions before calling this method. The error being generated
(at the ExecuteNonQuery() method) is this:

Line 1: Incorrect syntax near createUserAccount.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Line 1:
Incorrect syntax near createUserAccount.


Help!! Any thoughts? :)
Jack
 
G

Guest

Not sure if this is the problem but You may need to tell it that it is a
stored procedure, something like
objCommand.CommandType = CommandType.StoredProcedure
 
J

Jack Black

Paul, thanks for replying!

As soon as I saw your note, I just KNEW that I'd already included that
statement, because I remember typing it. Guess what?? ;-) I guess
I'd deleted it while tinkering with the code; once I put it back in,
the stored proc worked PERFECTLY! :)

Thanks again for keeping me honest! :D
Jack
 
G

Guest

glad it worked.
thanks for the reply.

Jack Black said:
Paul, thanks for replying!

As soon as I saw your note, I just KNEW that I'd already included that
statement, because I remember typing it. Guess what?? ;-) I guess
I'd deleted it while tinkering with the code; once I put it back in,
the stored proc worked PERFECTLY! :)

Thanks again for keeping me honest! :D
Jack
 

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

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top