Need help with my database

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

Join Date: Jun 2005
Posts: 21
Reputation: Yoshidex is an unknown quantity at this point 
Solved Threads: 0
Yoshidex's Avatar
Yoshidex Yoshidex is offline Offline
Newbie Poster

Need help with my database

 
0
  #1
Feb 1st, 2006
Hello there, is been a while since I last posted here, mostly because I didn't have the time I needed to program. But now, I reentered the exciting world in Visual Basic, 'cause I have a lot of time now and my mom wants me to make her a database :lol:
Anyway, I'm using VB 6.0 and I thought it was going to be easier than it's becomed. It all started when I tried to add a Search command button to the database the Data Form Object Wizard built. I searched through the internet and the forums and found out about SQL and ADO and read some tutorials on them, even the one that is posted at the beginning of the VB forum and decided to make one from scratch. But now, although my code seems right, it won't return me any records. I want the records to be input into Text Boxes. Here's the starting code I'm using in the Form_Load:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Form_Load()
  2.  
  3. Dim Pacdb As New ADODB.Connection
  4. Dim Pacrs As New ADODB.Recordset
  5. Dim Paccmd As New ADODB.Command
  6.  
  7. Pacdb.CursorLocation = adUseClient
  8. Pacdb.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Documents and Settings\Owner\My Documents\PruebaPropac\HistoriasClĂ­nicas.mdb;Mode=Read|Write"
  9. Pacdb.Open
  10.  
  11. With Paccmd
  12. .ActiveConnection = Pacdb
  13. .CommandText = "SELECT * FROM Pacientes ORDER BY Nombre;"
  14. .CommandType = adCmdText
  15. End With
  16.  
  17. With Pacrs
  18. .CursorType = adOpenStatic
  19. .CursorLocation = adUseClient
  20. .LockType = adLockOptimistic
  21. .Open Paccmd
  22. End With
Please help me, tell me what code I'm missing for the database to return each value in a predetermined text box.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: Yoshidex is an unknown quantity at this point 
Solved Threads: 0
Yoshidex's Avatar
Yoshidex Yoshidex is offline Offline
Newbie Poster

Re: Need help with my database

 
0
  #2
Feb 1st, 2006
I forgot to ask if there was a way of doing this easier with the Data Form Wizard, and if so, how to add the search command.
Thx again XD
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 13
Reputation: Manojsah is an unknown quantity at this point 
Solved Threads: 2
Manojsah Manojsah is offline Offline
Newbie Poster

Re: Need help with my database

 
0
  #3
Feb 3rd, 2006
Hello,
I am also a new user , but i know the connectivity,
please try the code below ??

manojsah




Private Sub Form_Load()


Dim Pacdb As New ADODB.Connection
Dim Pacrs As New ADODB.Recordset
'Dim Paccmd As New ADODB.Command
Dim str As String


Pacdb.Open = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Documents and Settings\Owner\My Documents\PruebaPropac\HistoriasClĂ­nicas.mdb;Mode=Read|Write"
str = "SELECT * FROM Pacientes ORDER BY Nombre;"
Pacrs.Open str, Pacdb, adOpenDynamic, adLockOptimistic
Pacrs.MoveFirst
text1.Text = (Pacrs!Attribute_name)

End Sub


Bye
manojsah
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: Yoshidex is an unknown quantity at this point 
Solved Threads: 0
Yoshidex's Avatar
Yoshidex Yoshidex is offline Offline
Newbie Poster

Re: Need help with my database

 
0
  #4
Feb 3rd, 2006
Hey man, thank you very much it really worked, except that you don't need the "=" after Pacdb.Open or it won't work, but everything else was a lot of help. Anyway, be aware of this thread because I will post more here if I have more problems with my database. Thanks a lot. :mrgreen:
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: Yoshidex is an unknown quantity at this point 
Solved Threads: 0
Yoshidex's Avatar
Yoshidex Yoshidex is offline Offline
Newbie Poster

Re: Need help with my database

 
0
  #5
Feb 3rd, 2006
Man, I can get it. What am I doing wrong? Now I want to see the next records using a button, just to see if they're there, but it returns me an error of:

"Arguments are of the wrong type, are out of acceptable range or are in conflict with one another"

When I press the button. Then, if I press the Debug option, it highlights the following part of the buttons code:

Private Sub Command1_Click()
Dim str As String
Dim Pacrs As New ADODB.Recordset

str = "SELECT * FROM Pacientes ORDER BY Nombre;"

'This is what the debug option highlights;
Pacrs.Open str, Pacdb, adOpenDynamic, adLockOptimistic 

If Not Pacrs.EOF Then
  Pacrs.MoveNext
End If

Pacrs.Close

End Sub

The rest of the code is already been post by manojsah. Can anyone tell me what did I do wrong?
Thanks in advance for the help you can provide.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 13
Reputation: Manojsah is an unknown quantity at this point 
Solved Threads: 2
Manojsah Manojsah is offline Offline
Newbie Poster

Re: Need help with my database

 
0
  #6
Feb 4th, 2006
Dear Friend,
Assume rs as your recordset now change the below code with your recordset variable
i.e pacrs
make one Command Button and make the changes in below code.

here (rs!agency_no)
agency_no is your attribute.........
Ok bye
Enjoy Programming
take care
Manoj




Private Sub Command1_Click()

rs.MoveNext
If rs.EOF Then
rs.MoveLast
MsgBox ("On Last record")
Else
rs.MoveNext
MsgBox(rs!agency_no)

End If


End Sub
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: Yoshidex is an unknown quantity at this point 
Solved Threads: 0
Yoshidex's Avatar
Yoshidex Yoshidex is offline Offline
Newbie Poster

Re: Need help with my database

 
0
  #7
Feb 4th, 2006
Thx again man, I can say now that this thread is solved.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC