Community discussion forum

Incorrect syntax near 'Calculation'.

  • 1 year ago

    I am using VS 2005 + SQL Server 2000.

    The piece of code is as follows

         Public Function GetAppId(ByRef AN As String) As String        Dim scon As New System.Data.SqlClient.SqlConnection ‘ declare the connection        scon.ConnectionString = ConfigurationManager.ConnectionStrings("strSimCon").ToString ‘ strSimCon is connection ‘ ‘string  stored in web.config file        scon.Open()’ opening of connection        Dim querystring As String = "Select AppCode From ApplicationData Where AppName=" & AN ‘ AN is the ‘ string which will contain Name of The application. On the basis of this name a unique ID will be retrieved.        Dim myCommand As New System.Data.SqlClient.SqlCommand(querystring, scon)        Dim sreader As System.Data.SqlClient.SqlDataReader       * sreader = myCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)’ I have tried using no  option or all other options .But no result.        GetAppId = sreader.GetString(0)        Return GetAppId

        End Function

     

    I am getting an error (exception) as System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'Calculation'.  Can anyone guide me what is not correct? 
  • 1 year ago

    HI

    it is error of u r sql query ok when it says incorrect syntax meance u r not passing u r query so try to pass right query
    cause this kind of error only appears when u made mistack in the query .
    hope this informtion will help u

     

  • 1 year ago

    Thanks Buddy..

    You were right. It took some time for me to understand where exactly the query was wrong....Anyways its working now...

    Thanks

     

  • 1 year ago

    you wel come buddy no problem if u have any proble abt the data base or ASP.net realted or any com throught .net ,Win32 api using .net Sqlserver5000 ask me no problem my id is ramdhavepreetam@gmail.com

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!