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()
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。
sbuggle
Member
4 Points
35 Posts
DSN behind the button click event
Feb 20, 2012 12:48 PM|LINK
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 '.'.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: DSN behind the button click event
Feb 22, 2012 12:20 AM|LINK
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。
sbuggle
Member
4 Points
35 Posts
Re: DSN behind the button click event
Feb 22, 2012 01:51 PM|LINK
This is Sybase and it works so could it be with the odbc drivers?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: DSN behind the button click event
Feb 22, 2012 11:53 PM|LINK
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