|
-
Mar 31st, 2003, 03:19 PM
#1
Thread Starter
Frenzied Member
ODBC Connection
I'm using an ODBC connection to connect to a SyBase Table. I connect to the DB ok, but It wont let me run a query. I get this error message on the line: objDR = cmd.ExecuteReader
Value of type 'Microsoft.Data.Odbc.OdbcDataReader' cannot be converted to 'System.Data.OleDb.OleDbDataReader'.
VB Code:
Dim cn As OdbcConnection
cn = New OdbcConnection("DSN=SBPROD;Server=SYBASE;DB=fmsprod;Password=test;User ID=test")
Dim cmd As New OdbcCommand(sqlcmd)
Try
cn.Open()
objDR = cmd.ExecuteReader
If objDR.Read = True Then
gerror_flag = True
Else
gerror_flag = False
End If
cn.Close()
Catch ex As Exception
MsgBox(Err.Description)
End Try
All I'm trying to do is see if any records are being retured...just a EOF test.
-
Apr 1st, 2003, 04:48 AM
#2
Use Count(*)
VB Code:
Dim cn As OdbcConnection
cn = New OdbcConnection("DSN=SBPROD;Server=SYBASE;DB=fmsprod;Password=test;User ID=test")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT Count(*) FROM mytable WHERE ...........", cn)
Dim myCount As Integer = CInt(cmd.ExecuteScalar())
gerror_flag = myCount > 0
-
Apr 1st, 2003, 04:52 AM
#3
and make sure you pass the connection to the command, only now I noticed that you don't...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|