|
-
Jan 8th, 2000, 01:36 AM
#1
Thread Starter
Lively Member
What is the easiest way to access an Access 2000 database with VB6? All I am getting is an unreconized database format error. Is there some data.ocx update I can download or do I have to jump through hoops first?
-
Jan 8th, 2000, 01:39 AM
#2
Guru
lately, I've answered this same question every 2 or 3 days ......
http://support.microsoft.com/support...G=ENG&SA=ALLKB
Tom
-
Jan 8th, 2000, 01:45 AM
#3
Addicted Member
Hi Nias
I have tried several things to do the very same and unfortunatly there is no control upgrade or anything.... you have to write code for everything..... but I found that if you make a good function once... it deals for all situations...... reply if you wnat an example.
-
Jan 8th, 2000, 02:33 AM
#4
Thread Starter
Lively Member
If you have sample code that would be terrific. That is what I am looking for. I thought for sure I could download an OCX for it from MSDN but no luck. Thanks everyone for the quick response. I only found this site today and I found it very resourceful!
-
Jan 8th, 2000, 12:21 PM
#5
-
Jan 8th, 2000, 07:00 PM
#6
Lively Member
You could just get access 2000 to save the database in a access 97 format.
Or use the ADO control
-
Jan 8th, 2000, 10:08 PM
#7
Hyperactive Member
Clunietp has more than likely already covered this but here goes.
1. Use code. This can be one of two ways DAO (Data Access Objects) or ADO (ActiveX Data Objects).
2. Use a data access control. Again this can be DAO or ADO.
---------------
ADO code will look like
Code:
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sCnn As String
sCnn = "Provider= Microsoft.Jet.OLEDB.4.0; Data Source= full path to your db;"
'This opens the connection to the database spedcified in the string.
cnn.Open sCnn
'Opens the recordset. The sting is the sort of string your Access queries generate.
rst.Open "SELECT * FROM atable", cnn, adOpenKeyset, adLockOptimistic
'This just scrolls through the records and updates the immediates window with a value.
With rst
.MoveFirst
Do While Not rst.EOF
Debug.Print ![afieldname]
Debug.Print
.MoveNext
Loop
End With
End Sub
Apologies the previous code was crappy and had loads of typos....
[This message has been edited by gravyboy (edited 01-12-2000).]
-
Jan 9th, 2000, 08:33 AM
#8
Thread Starter
Lively Member
Ok,
Using the code found at: http://support.microsoft.com/support...G=ENG&SA=ALLKB as described above (I did find it very useful) how do I modify it to open a table using a query. I know I am pretty close but something isn't quite working right. I tried the code example pasted here but it errored out on the sCnn string. I did have success opening the table and viewing the data but I want to apply a query with an order by clause without resorting the table.
-
Jan 9th, 2000, 09:33 AM
#9
Thread Starter
Lively Member
DOH!
I think I figured it out. It seems I had the coding correct to begin with, but my SQL query was comparing date fields and if I use 1/18/00 (for instance) in my query I get a divide by zero error. If I put the dates in different formats yyyy/mm/dd or yy/mm/dd (for instance) I get all data back (date doesn't work). If I put in 1/18/99 it works great (as long as I want last years stuff).
For now I will put the query in Access and move on but if anybody has a resolution on this one let me know please.
Nias
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|