Link to home
Start Free TrialLog in
Avatar of Milkus1
Milkus1Flag for Australia

asked on

Cant fill using Odbc.OdbcDataAdapter ...Why?

Here is my code. I was using sqlclient.sqldataadapter prior, but had to change due to the application's development.
I have moved to Odbc, but now cant get datasets to fill. What am I missing. The connection is open...

        Dim lsSQL As String
        Dim lrs As New Odbc.OdbcDataAdapter
        Dim lCommand As Odbc.OdbcCommand
        Dim ds As New DataSet

        Login = False
        lsSQL = "Select * FROM tblUser " ' WHERE UserName = " & qStrSQL(User) & " AND activeFlg = 1"
        'lsSQL = "Select * FROM tblUser WHERE UserName = " & qStrSQL(User) & " AND activeFlg = 1"
        lCommand = New Odbc.OdbcCommand(lsSQL, gConn)
        lrs.SelectCommand = lCommand

        lrs.Fill(ds)
Avatar of rodmjay
rodmjay
Flag of United States of America image

does the qStrSQL function add the single quotes to the string?  That is the only thing that i can think of
Try this

"select * from tblUser where (username = '" + qStrSQL(User) + "') and (activeFlg = 1)"
Dim lsSQL As String
        Dim lrs As New Odbc.OdbcDataAdapter
        Dim ds As New DataSet

        Login = False
        lsSQL = "Select * FROM tblUser "
        lrs = new Odbc.OdbcDataAdapter("SELECT * FROM tblUser", gConn);
        lrs.Fill(ds)
ASKER CERTIFIED SOLUTION
Avatar of checoo
checoo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Milkus1

ASKER

Thanks for the replies

qstrSql is places the single quotes in the string.
Brackets don t make a difference and testing the statement without the Where clause still fails
No luck with any of the others ;o(
Avatar of Milkus1

ASKER

The answer is...

My connection string used a standard DSN connection format not the SQL server format.
Therefore the connection opened by the errors were caused during execution of statements
thanks for everyones help