×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem retrieving records

Problem retrieving records

Problem retrieving records

(OP)
I think I need an extra pair of eyes - or two - to tell me what I'm missing.

Using VB6, ADO 2.5 and Access '03, I've created a small program to retrieve/update data.  However, it's not retrieving!

Basically, the process is:

CODE

' in declarations: -----------------------------
Global cmdSQL As String
Global cnTrain As ADODB.Connection
Global cmTrain As ADODB.Command
Global rsTrain As ADODB.Recordset

' at AppInit: ----------------------------------
    dbName = App.Path + "\LogIn.mdb"
    Set cnTrain = New ADODB.Connection
    cnTrain.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" + _
        "Data Source=" + dbName + ";"
    cnTrain.Open
    Set cmTrain = New ADODB.Command
    cmTrain.ActiveConnection = cnTrain
    Set rsTrain = New ADODB.Recordset

' at user input: -------------------------------
    cmdSQL = "select * from TrainFile where " + _
             "SSN like '*" + txtSSN4 + "' and " + _
             "LName like '*" + txtLName + "*'"
    cmTrain.CommandType = adCmdText
    cmTrain.CommandText = cmdSQL
    rsTrain.Open cmTrain

The problem: rsTrain.BOF and rsTrain.EOF is always true.  I can copy/paste cmTrain.CommandText into a query in the Access database, and it returns exactly the record(s) I expect to see.

After cnTrain.Open is executed, cnTrain.State=1 so I'm sure it's connected.

This is a process I use daily at work, (against DB2 and SQL Server databases), so I'm sure it should work.

I figure there's got to be some simple little thing I'm overlooking.  If your eyes spot it, please let me know!

RE: Problem retrieving records

At first glance, you are using + to concatenate strings. Use & instead. + gives unreliable results, in certain cases trying to add string values instead of appending.

Cogito eggo sum – I think, therefore I am a waffle.
 

RE: Problem retrieving records

(OP)
For what it's worth: I managed to get around the problem - by changing the Access interface to DAO 3.6, (but keeping ADO for the DB2 interface).

So far, everything's working just fine, even with + concatenation instead of &.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close