Current location: Hot Scripts Forums » Programming Languages » Visual Basic » not able to connect access databse via vb6.0


not able to connect access databse via vb6.0

Reply
  #1 (permalink)  
Old 10-31-03, 03:33 AM
traceMe traceMe is offline
Newbie Coder
 
Join Date: Oct 2003
Location: india(mumbai)
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Question not able to connect access databse via vb6.0

I have access database and vb6.0 to work on. i dont know how to connect the database through vb here is the code that i have written
i get "unrecognized database format 'd:\shop\shop.mdb'."
i have set references to microsoft ActiveX Data Objects 2.0 Library
is there any other references that i have to set to access ms access database
This is my code which is placed in onclick action of button
vb Code:
  1. Set conShop = New Connection
  2. Set rsShop = New Recordset
  3. With conShop
  4. .Provider = "MICROSOFT.JET.OLEDB.3.51"
  5. .ConnectionString = "data Source= d:/shop/shop.mdb"
  6. .Open
  7. End With
  8.  
  9. rsShop.Open "select * From [user] where username='" & Trim(txtName.Text) & "' and pwd='" & Trim(txtPwd.Text) & "'", conShop, adLockOptimistic, adOpenDynamic
  10. If txtName = "test" Then
  11. frmAdmin.Show
  12. Else
  13. MsgBox "Incorrect Username Or Password"
  14. End If
this is really very urgent if people can help me
that would be great full

Last edited by digioz; 03-15-08 at 04:35 PM. Reason: Use Code Tags
Reply With Quote
  #2 (permalink)  
Old 10-31-03, 04:06 PM
Huuf Huuf is offline
New Member
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
vb Code:
  1. Option Explicit
  2. Dim DbaseConn As ADODB.Connection
  3. Dim RecSet As ADODB.RecordSet
  4. Dim RecSet2 As ADODB.RecordSet
  5. Dim SQL As String
  6.  
  7. Public Sub AddATable()
  8. On Error Resume Next
  9. SQL = "CREATE TABLE NAME_OF_TABLE (Fields MEMO);"
  10. Call RecordSet
  11. Conn
  12. DbaseConn.Execute SQL
  13. Dim blnTrue As Boolean
  14. Dim tel, Tempe
  15. Dim FreeF
  16. FreeF = FreeFile
  17. 'Add Values
  18. SQL = "SELECT Fields FROM NAME_OF_TABLE"
  19. Call RecordSet
  20. RecSet.Open (SQL)
  21. RecSet.AddNew
  22. RecSet("Fields") = "test
  23. RecSet.Update
  24. End Sub
  25. Public Sub Conn()
  26. Set DbaseConn = New ADODB.Connection
  27. DbaseConn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= d:/shop/shop.mdb;"
  28. End Sub
  29. Public Sub RecordSet()
  30. Set RecSet = New ADODB.RecordSet
  31. RecSet.ActiveConnection = DbaseConn
  32. RecSet.CursorLocation = adUseClient
  33. RecSet.CursorType = adOpenDynamic
  34. RecSet.LockType = adLockOptimistic
  35. End Sub
  36. Private Sub Form_Load()
  37. AddATable
  38. End Sub

Last edited by digioz; 03-15-08 at 04:35 PM. Reason: Use Code Tags
Reply With Quote
  #3 (permalink)  
Old 10-31-03, 11:37 PM
traceMe traceMe is offline
Newbie Coder
 
Join Date: Oct 2003
Location: india(mumbai)
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
thx buddy

hey,
used this code and its working fine now able to communicate to db.
thx for ur help.....
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date From Access 2000 Database Kaikki ASP 4 09-25-03 06:04 PM
mysql to access aspuser25 Database 2 09-16-03 11:01 AM
Looking for Registered Members area access to files .. script zamen Script Requests 3 09-02-03 05:44 AM


All times are GMT -5. The time now is 01:15 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.