By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,505 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,505 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"Jack Black" wrote:
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

Nov 19 '05 #2

P: n/a
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

On Tue, 19 Apr 2005 16:15:01 -0700, "Paul"
<Pa**@discussions.microsoft.com> wrote:
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


Nov 19 '05 #3

P: n/a
glad it worked.
thanks for the reply.

"Jack Black" wrote:
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

On Tue, 19 Apr 2005 16:15:01 -0700, "Paul"
<Pa**@discussions.microsoft.com> wrote:
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


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.