Computing.Net > Forums > Programming > Data not saving in Database..|

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Data not saving in Database..|

Reply to Message Icon

Name: gardenair
Date: May 17, 2003 at 20:39:13 Pacific
OS: win98
CPU/Ram: 166
Comment:

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.Open

If 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 Sub

Coding 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 Sub

Thanks in advance your your guidence.



Sponsored Link
Ads by Google

Response Number 1
Name: jer
Date: May 20, 2003 at 02:42:27 Pacific
Reply:

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.Text

Just to avoid giving non-value errors.


0
Reply to Message Icon

Related Posts

See More


Timing loop using ‘C’ Counting without getche()...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Data not saving in Database..|

MySQL/Perl losing data in database table www.computing.net/answers/programming/mysqlperl-losing-data-in-database-table/2100.html

This web page may not save correctly www.computing.net/answers/programming/this-web-page-may-not-save-correctly/398.html

Dos/win98 - hdd read/write requst? www.computing.net/answers/programming/doswin98-hdd-readwrite-requst/10860.html