Incorrect Syntax Near... Error Message

Discussion in 'ASP .Net' started by Joe, Nov 8, 2009.

  1. Joe

    Joe Guest

    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?
    Joe, Nov 8, 2009
    #1
    1. Advertising

  2. Joe

    Scott M. Guest

    "Joe" <> wrote in message
    news:...
    > 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
    Scott M., Nov 8, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,708
    Patrick.O.Ige
    Oct 11, 2004
  2. Patrick Olurotimi Ige
    Replies:
    4
    Views:
    7,017
    Patrick Olurotimi Ige
    Mar 18, 2005
  3. JMUApache
    Replies:
    2
    Views:
    3,301
    Brendan Reynolds
    Sep 4, 2005
  4. David

    Incorrect syntax near 'int'

    David, Apr 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    2,472
    David
    Apr 7, 2006
  5. Dax
    Replies:
    1
    Views:
    228
    Bob Barrows [MVP]
    Feb 13, 2007
Loading...

Share This Page