• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

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)
0
Milkus1
Asked:
Milkus1
1 Solution
 
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
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
checooCommented:
       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
 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now