locked
DSN behind the button click event RRS feed

  • Question

  • User-515183 posted

    Hello,

    I am trying to connect to Sybase using the odbcConnection and want to put the code in the vb file behind the button click event to retrieve the row of data and put it in the text boxes on the form.  I am getting an error on line below. Do I have to use the console to display the data with the datareader or is there a better way.  Thank you in advance if anyone can suggest. The actual error is below.

      Dim con As New OdbcConnection()
            con = New OdbcConnection("DSN=;Uid=;Pwd=")



            Dim sql As String = "SELECT dbo.Pat.firstName, dbo.Pat.middleName, dbo.Pat.lastName, dbo.Pat.sexCd, dbo.Pat.SSN, dbo.Pat.birthDt, dbo.ExtPat.MRNum" & _
                         "FROM dbo.ExtPat, dbo.Pat WHERE dbo.ExtPat.PID = dbo.Pat.PID AND (dbo.ExtPat.MRNum = '001839995')"

            Dim myCommand As New OdbcCommand(sql, con)
            con.Open()
            Dim myReader As OdbcDataReader = myCommand.ExecuteReader()
            Do While myReader.Read()

            Loop

    ERROR [42000] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]Incorrect syntax near '.'.

    Monday, February 20, 2012 8:48 AM

All replies

  • User3866881 posted

    ERROR [42000] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]Incorrect syntax near '.'.

    Hello:)

    This error means that your syntax is wrong,and I strongly suggest you trying to put the sql string into the running time(something like the SQL Managetment Studio in your Sydatabase……)to check whether the sql is wrong or not。So the problem can be solved。

    Tuesday, February 21, 2012 8:20 PM
  • User-515183 posted

    This is Sybase and it works so could it be with the odbc drivers? 

    Wednesday, February 22, 2012 9:51 AM
  • User3866881 posted

    This is Sybase and it works so could it be with the odbc drivers? 

    Not very sure,but I still suggest you downloading the .NET DataBase for ADO.NET providor for that specific database:http://www.datadirect.com/products/net/net-for-sybase/index.html

    Wednesday, February 22, 2012 7:53 PM