Incorrect Syntax Near... Error Message

J

Joe

Hi,

When I execute the code below, I get an error message
"Incorrect syntax near usp_Has_Access".

Shared DefaultDBConn As String = ConfigurationManager.ConnectionStrings
("QuickSize_WebConnectionString").ConnectionString
Public Shared Function IsUserAuthorized(ByVal sLanID As String) As
Boolean
Dim cnQuickSizeWeb As New SqlConnection(DefaultDBConn)
Dim cmdAuthorization As SqlCommand = New SqlCommand

With cmdAuthorization
.Connection = cnQuickSizeWeb
.CommandType = SqlDataSourceCommandType.StoredProcedure
.CommandText = "usp_Has_Access"
.Parameters.AddWithValue("@LANID", sLanID)
cnQuickSizeWeb.Open()
Try
Dim rowsAffected As Integer = .ExecuteNonQuery()
Console.WriteLine("RowsAffected: {0}", rowsAffected)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
cnQuickSizeWeb.Close()
End With
End Function

The stored procedure usp_Has_Access has one input parameter, @LANID
which is a varchar and it runs fine when I execute it from SQL Server
Management Studio. Can anyone tell me what I am doing wrong?
 
S

Scott M.

Joe said:
Hi,

When I execute the code below, I get an error message
"Incorrect syntax near usp_Has_Access".

Shared DefaultDBConn As String = ConfigurationManager.ConnectionStrings
("QuickSize_WebConnectionString").ConnectionString
Public Shared Function IsUserAuthorized(ByVal sLanID As String) As
Boolean
Dim cnQuickSizeWeb As New SqlConnection(DefaultDBConn)
Dim cmdAuthorization As SqlCommand = New SqlCommand

With cmdAuthorization
.Connection = cnQuickSizeWeb
.CommandType = SqlDataSourceCommandType.StoredProcedure
.CommandText = "usp_Has_Access"
.Parameters.AddWithValue("@LANID", sLanID)
cnQuickSizeWeb.Open()
Try
Dim rowsAffected As Integer = .ExecuteNonQuery()
Console.WriteLine("RowsAffected: {0}", rowsAffected)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
cnQuickSizeWeb.Close()
End With
End Function

The stored procedure usp_Has_Access has one input parameter, @LANID
which is a varchar and it runs fine when I execute it from SQL Server
Management Studio. Can anyone tell me what I am doing wrong?

Does usp_Has_Access run correctly when run directly?

-Scott
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top