Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Iam facing a problem regarding to store my data in the database.Iam using Visual basic 6 as frunt end & back end Oracle8.
The problem is that i have two table .The First table is Patient infomation i.e "Patient_info". In patient info i store all patient personal information like ,Patient Nmae,Father name ,address Phone number etc. I use Text boxes to input data & it successfully store my data in the database table .
In the next form i use it to input patient symptoms & want to store the data in the which is Patient_history table i.e "Patient_his" .In this form i simply display the Patient Name & Father name in the Lable boxes so that the user can vie that which patient_symptoms he is wring in the text boxes.
The problem rises when i input all the data in the respectives text boxes & press the Save button .It gives me a messages "Record has been saved" which i write in the code of save button but when i open my database & write the query "Select * from patient_his" it shows "No Row Selected" . This Means that the data is not saved in the database.
Visual basic is not showing any error .It works fine durning saving .I have tryed my best & spend lot of hours to find the logical error that why VB is not saving my data in the second table.
Remember that data saves successfully in my 1st table i.e "patient_info" but not in Second table i.e "patient_his".
My coding of patient_his is as under....see it carefully & guide me with your experiance.Dim rec2 As ADODB.Recordset
Private Sub Form_Load()
Set rec2 = New ADODB.Recordset
Set rec2.ActiveConnection = cn
rec2.CursorType = adOpenDynamic
rec2.LockType = adLockBatchOptimistic
rec2.Source = "patient_his"
rec2.OpenIf Not rec2.BOF Then '----Table Patient_his----
rec2.MoveFirst
lblPid_value.Caption = rec2.Fields(0)
lblSerial_no.Caption = rec2.Fields(1)
txtVa_l.Text = rec2.Fields(2)
txtVa_r.Text = rec2.Fields(3)
txtLa_l.Text = rec2.Fields(4)
txtLa_r.Text = rec2.Fields(5)
End If
End SubCoding in Save Button is
Private Sub cmdSave_Pcom_Click()
rec2.AddNew
rec2.Fields(0) = lblPid_value.Caption
rec2.Fields(1) = lblSerial_no.Caption
rec2.Fields(2) = txtVa_l.Text
rec2.Fields(3) = txtVa_r.Text
rec2.Fields(4) = txtLa_l.Text
rec2.Fields(5) = txtLa_r.Text
rec2.Update
MsgBox "record has been Saved"
cmdSave_Pcom.Enabled = False
End SubThanks in advance your your guidence.

1)Is the first table(the one that is saving data) in Oracle8? 2)Are you using the same recordset variable and not closing it before using it again? Nothing wrong with the code but I would also use:
rec2.Fields(2) = "" & txtVa_l.TextJust to avoid giving non-value errors.

![]() |
Timing loop using ‘C’
|
Counting without getche()...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |