View Full Version : Vb.net Save Button Linked To Database-please Help!!!!!!


shelly121
18-02-2005, 12:16
'SAVE BUTTON
Private Sub ButSAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntSave.Click
RS = New ADODB.Recordset()
RS.Open("select * from client order by Name", CN, 1, 2)

RS.AddNew()

txtFirstName.Text = CStr(RS.Fields("Name").Value)

hey ppl!! ive got the above code for my save button, in a vb.net application which is linked to microsoft access database, however when i open.play the form it works fine except for when i press "save" it comes up with the following error:
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

Additional information: Cast from type 'DBNull' to type 'String' is not valid.
sum1 please help, be grateful for any ideas/help!!!

fnkysknky
18-02-2005, 14:16
No offence intended but with all these questions are they actually teaching you anything? :suspect:

JoeP
18-02-2005, 14:49
Shelly,

It's a similar error to what we handled yesterday - going from Null to string.

I'm not a VB.Net expert, but I would expect it's because the record you've added has nothing in it.

Joe