View Poll Results: Easiest way to connect to a MS Access DB
- Voters
- 7. You may not vote on this poll
-
Sep 14th, 2005, 01:41 PM
#1
Thread Starter
Addicted Member
[RESOLVED] ADODB/MS Access 97 conflicts
ok I'm using an ADODB connection to connect VB6 to a MS Access 97 database. Now I converted the database from a MS Access 2003 database, and because of this I can not change the data in the database. My question is: can somone point me on how to set up an ODBC connection with VB to connect to a MS Access 2003 database so that I can manipulate the data?
VB Code:
[FONT=Lucida Console]'Create a new connection --
Set adoConnection = New ADODB.Connection
'Create a new recordset --
Set adoRecordset = New ADODB.Recordset
'Build our connection string to use when we open the connection --
connectString = "Provider=Microsoft.Jet.OLEDB.3.51;" _
& "Data Source=C:\Documents and Settings\P6B0438\Desktop\CycleCount.mdb"
adoConnection.Open connectString
adoRecordset.Open "SECURITY", adoConnection
Do Until adoRecordset.EOF
If (adoRecordset!UserName = txtUserName.Text) Then
Dim str As String
str = txtOldPassword.Text
If (adoRecordset!Password = txtOldPassword.Text) Then
[B]'this line does not work
adoRecordset!Password = txtNewPassword1.Text[/B]
End If
MsgBox ("The password should have been changed from " & str & " to " & adoRecordset!Password)
End If
adoRecordset.MoveNext
Loop[/FONT]
Edit: Added [vbcode][/vbcode] tags for clairty. - Hack
Last edited by Hack; Sep 14th, 2005 at 01:44 PM.
-
Sep 14th, 2005, 02:56 PM
#2
Re: ADODB/MS Access 97 conflicts
Take a look at the ADO/Access example in my signature
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Sep 14th, 2005, 03:11 PM
#3
Re: ADODB/MS Access 97 conflicts
Where is DAO? And don't say its old. A pole should have all options.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Sep 14th, 2005, 03:26 PM
#4
Thread Starter
Addicted Member
Re: ADODB/MS Access 97 conflicts
-
Sep 14th, 2005, 03:47 PM
#5
Re: ADODB/MS Access 97 conflicts
DAO is the predecessor to ADO, and I certainly cannot advise it's use - I believe support for it has ended, or will soon. It also has less functionality than ADO.
The trouble with your code above is with your "adoRecordset.Open " line, you have not specified enough parameters to be able to write to it. If you don't specify otherwise, you get a forward-only, read-only recordset.
Try this instead:
VB Code:
adoRecordset.Open "SECURITY", adoConnection, adOpenDynamic, adLockOptimistic
-
Sep 14th, 2005, 04:53 PM
#6
Re: ADODB/MS Access 97 conflicts
 Originally Posted by manofsteel00
What is DAO?
DAO = Data Access Objects. The last version was 3.6 which will open an Access 2000 DB.
It maybe old but you can still download v3.6 from M$.
Last edited by Keithuk; Sep 14th, 2005 at 04:57 PM.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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
|