accessing ms access from VB

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2007
Posts: 6
Reputation: rumi is an unknown quantity at this point 
Solved Threads: 0
rumi's Avatar
rumi rumi is offline Offline
Newbie Poster

Re: accessing ms access from VB

 
0
  #11
Jul 26th, 2007
yes. infact that was my main mistake!ive tried other methods as well..thanx for reminding me bout that,jireh..
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: accessing ms access from VB

 
0
  #12
Jul 26th, 2007
Originally Posted by rumi View Post
yes. infact that was my main mistake!ive tried other methods as well..thanx for reminding me bout that,jireh..
So does your problem is solved?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 6
Reputation: rumi is an unknown quantity at this point 
Solved Threads: 0
rumi's Avatar
rumi rumi is offline Offline
Newbie Poster

Re: accessing ms access from VB

 
0
  #13
Jul 27th, 2007
yes,quite but now im facing another problem.. i tried using loops to check whether Reservation made by customer have been occupied before saving the record,so i used these..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub CmdSave_Click()
  2. Adodc1.Recordset.MoveFirst
  3. Do While Not Adodc1.Recordset.EOF
  4. If Adodc1.Recordset.Fields("Reserv_Date").Value = Txt_Date.Text And Adodc1.Recordset.Fields("Booking_Time").Value = Txt_Time.Text And Adodc1.Recordset.Fields("Fac_Type").Value = Cmb_Type.Text Then
  5. Txt_Date.Text = ""
  6. Txt_Time.Text = ""
  7. Txt_Date.SetFocus
  8. DisableButtons
  9. CmdSave.Enabled = True
  10. CmdAddNew.Caption = "&Cancel"
  11. MsgBox "Reservation occupied! Please choose another date and time", vbOKOnly
  12. Exit Sub
  13. End If
  14. Adodc1.Recordset.MoveNext
  15. Loop
  16. Adodc1.Recordset.Requery
  17. If Adodc1.Recordset.Fields("Reserv_Date").Value <> Txt_Date.Text And Adodc1.Recordset.Fields("Booking_Time").Value <> Txt_Time.Text And Adodc1.Recordset.Fields("Fac_Type").Value = Cmb_Type.Text Then
  18. Adodc1.Recordset.Update
  19. EnableButtons
  20. CmdSave.Enabled = False
  21. CmdAddNew.Caption = "&Add New"
  22. MsgBox "Records are succesfully saved!", vbOKOnly
  23. End If
  24. End Sub

but it never work..do u have any idea how?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: accessing ms access from VB

 
0
  #14
Jul 27th, 2007
try this one hope it would work because I've never use adodc...

Function savecheck() As Boolean
   Dim rs as recordset for adodb sorry I don't know how 
   savecheck = True
Set rs= open the recordset for that table ...
the query in your rs must be like this "select * from [tablename] where Reserv_Date+Booking_Time+Fac_Type = '" & Txt_Date.Text + Txt_Time.Text  + Cmb_Type.Text & "'"
   if Not rs.Eof then
      savecheck=False
      Msgbox "Already occupied!" 
      Exit Function
   End if
End If

Private Sub CmdSave_Click()
    If savecheck Then
       put your code here that will save your data entry
   End if
Ens Sub
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 6
Reputation: rumi is an unknown quantity at this point 
Solved Threads: 0
rumi's Avatar
rumi rumi is offline Offline
Newbie Poster

Re: accessing ms access from VB

 
0
  #15
Jul 29th, 2007
hi there jireh..
i tried blending in your codes with the use of adodc but it nvr seem to work..i found the logic of your codes appropriate for my program but i just dont know how to make a query with the use of adodc..it seems that adodc simplifies the steps in connecting from vb to database(everything is almost auto)but i still cant figure out a way.i know you never use adodc before but if you happen to have any idea on resolving my problem please send feedbacks k..thanx so much
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 3
Reputation: elleinad is an unknown quantity at this point 
Solved Threads: 0
elleinad elleinad is offline Offline
Newbie Poster

Re: accessing ms access from VB

 
0
  #16
May 1st, 2008
How do i access only a column from MS access to VB?
I am also newbie on VB.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 2
Reputation: roshani285 is an unknown quantity at this point 
Solved Threads: 0
roshani285 roshani285 is offline Offline
Newbie Poster

Re: accessing ms access from VB

 
0
  #17
May 2nd, 2008
Originally Posted by anud18 View Post
hi....i m actually developing a tool which uses access as the database source...i hv created 2 coloumns in the database....username and password....now in my tool i need to ask the user fr his username and password....if it matches with any of the combinations stored in the database then the user can login ....cn anyone help me wiith dis ....
First create Connectivity with your database with DAta control or ADODC control or by ADODB . If you are useing ADODB connection then create recordset to access your table and then compare all values of ur table with username and password given by user.
like this way: if rs is recordset then code will be like---------
rs.open("select * from tbluser where loginname = '" & txtlogin.text & "' and password = '" & txtpassword.text & "'"),cn
if rs.recordcount > 0 then
''' login successfully
else
''' cant login
end if
----- try this code with your table name and column name....
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: accessing ms access from VB

 
0
  #18
Jan 13th, 2009
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. option Explicit
  2.  
  3. Private Sub cmdAccept_Click()
  4. Dim cn As New ADODB.Connection
  5. Dim strCNString As String
  6. Dim rs As New ADODB.Recordset
  7. Dim Txt As String
  8.  
  9. On Error GoTo ErrHandler
  10. 'Connect to database
  11. strCNString = "Data Source=" & App.Path & "\databasename.mdb"
  12. cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
  13. cn.ConnectionString = strCNString
  14. cn.Properties("Jet OLEDB:Database Password") = ""
  15. cn.Open
  16. 'Open recordsource
  17. With rs
  18. .Open "Select * from tablename where name='" & txtName.Text & "' and Password='" & txtPassword.Text & "'", cn, adOpenDynamic, adLockOptimistic
  19. 'Check username and password
  20. If .EOF Then
  21. MsgBox "Access Denied...Password and name do not match,Please enter correct Details!", vbOKOnly + vbCritical, "Security Login"
  22. txtName.Text = ""
  23. txtPassword.Text = ""
  24. txtName.SetFocus
  25. cn.Close
  26. Else
  27. Txt = "" & " " & UCase$(txtName.Text) & ""
  28. MsgBox "Welcome!!!" & Txt, vbOKOnly + vbExclamation, "Security Login"
  29.  
  30. cn.Close
  31. Unload Me
  32. frmform2.Show
  33.  
  34. End If
  35. End With
  36.  
  37. ExitHere:
  38. Exit Sub
  39.  
  40. ErrHandler:
  41. MsgBox Err.Number & " " & Err.Description, vbCritical, "Login ..."
  42. cn.Close
  43. End Sub
  44.  
  45. Private Sub Form_Load()
  46. txtPassword.PasswordChar = "*"
  47.  
  48. End Sub
Last edited by Ancient Dragon; Jan 13th, 2009 at 10:55 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 21
Reputation: sackymatt is an unknown quantity at this point 
Solved Threads: 0
sackymatt sackymatt is offline Offline
Newbie Poster

Re: accessing ms access from VB

 
0
  #19
Jan 13th, 2009
hope that code helps u anud
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 4094 | Replies: 18
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC