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)
Milkus1Asked:
Who is Participating?
 
checooConnect With a Mentor Commented:
       Dim lsSQL As String
        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"
         Dim lrs As New Odbc.OdbcDataAdapter(lsSQL,gConn)

        lrs.Fill(ds,"tblUser")
0
 
rodmjayCommented:
does the qStrSQL function add the single quotes to the string?  That is the only thing that i can think of
0
 
rodmjayCommented:
Try this

"select * from tblUser where (username = '" + qStrSQL(User) + "') and (activeFlg = 1)"
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
dunglaCommented:
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)
0
 
Milkus1Author Commented:
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(
0
 
Milkus1Author Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.