Re: Run query using VB6 and DAO
From: Wart (nospamWart_at_epix.net)
Date: 11/26/04
- Next message: Paul Clement: "Re: Interfacing access 97 database"
- Previous message: William \(Bill\) Vaughn: "Re: best practices to support multi-users"
- In reply to: Stefanie: "Run query using VB6 and DAO"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 26 Nov 2004 18:39:51 -0500
Stefanie,
I would suggest ADO instead of DAO.
Depending on your database, make a connection to it using the ADO connection
object.
Use the Connection to open a RecordSet.
Iterate through the RecordSet for your results.
The easiest way to use the parameter from your TextBox would be inline SQL
but there will be a cry from others about the security hole this creates and
so you should look into parameterized queries when you have more comfort.
So somewhere in your app you could do something like as follows:
Dim lsSql as string
lsSql = "Select * from MyTable where Field1 = '" & MyTextBox.Text & "'"
MyRs.Open lsSql, MyConnection, adOpenStatic, adLockOptimistic
Do While Not MyRS.EOF
TextField1 = MyRS.Fields(0)
TextField2 = MyRS.Fields(1)
'Write to the file
MyRS.MoveNext
Loop
HTH,
CF
"Stefanie" <Stefanie@zsmail.net> wrote in message
news:%232CDgq%230EHA.1192@tk2msftngp13.phx.gbl...
> Hi,
>
> I'am new to database programming so please be patient.
>
> I created a database with one table (two fields) and one query (both
> fields from the table and sorted)
> Now i'd like to run this query from my VB6 application with some input.
> So i have a textbox on my form for a parameter in my query.
> How can i receive the values from field 1 and field 2 running my query.
> (I have to write these values to a file)
>
> (BTW i'am using DAO but i don't know if this is the best for a table with
> about 2,000,000 records.)
>
> Q1: How to run the query with a parameter from my textbox
> Q2: How to receive te results (i know how to write them to a file)
>
> Stefanie
>
>
>
- Next message: Paul Clement: "Re: Interfacing access 97 database"
- Previous message: William \(Bill\) Vaughn: "Re: best practices to support multi-users"
- In reply to: Stefanie: "Run query using VB6 and DAO"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|