| | |
Need help with my database
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
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:
Please help me, tell me what code I'm missing for the database to return each value in a predetermined text box.
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)
Private Sub Form_Load() Dim Pacdb As New ADODB.Connection Dim Pacrs As New ADODB.Recordset Dim Paccmd As New ADODB.Command Pacdb.CursorLocation = adUseClient Pacdb.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Documents and Settings\Owner\My Documents\PruebaPropac\HistoriasClĂnicas.mdb;Mode=Read|Write" Pacdb.Open With Paccmd .ActiveConnection = Pacdb .CommandText = "SELECT * FROM Pacientes ORDER BY Nombre;" .CommandType = adCmdText End With With Pacrs .CursorType = adOpenStatic .CursorLocation = adUseClient .LockType = adLockOptimistic .Open Paccmd End With
•
•
Join Date: Aug 2005
Posts: 13
Reputation:
Solved Threads: 2
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
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
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:
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.
"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 SubThe 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.
•
•
Join Date: Aug 2005
Posts: 13
Reputation:
Solved Threads: 2
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
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
![]() |
Similar Threads
- VB: Connect to Access database via ODBC datasource name (Visual Basic 4 / 5 / 6)
- Writing to an Access Database (Visual Basic 4 / 5 / 6)
- Backing up a MySQL database (MySQL)
- Writing to an Access Database using Java... (Java)
- Redid the Database from Scratch (DaniWeb Community Feedback)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: progress bar problem in vb
- Next Thread: Task Schedular
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





