Insert statement doesnt work...

Komalj

Member
Joined
Aug 24, 2004
Messages
14
Programming Experience
1-3
Hi
I have a table in MS Access....that contains fields
ID (number)
Name (Text)
Date_Issue (Date)
Date_Return (date)
Flag (Yes/No)

Now in my windows from i have a combobox, testbox, listbox and datepicker.

I want to insert values from these controls to my table....

I m using the following syntax
"INSERT INTO Table(ID,Name,Date_of_Issue,Date_of_Return,Flag) Values (" & ListBox1.SelectedValue & ",'" & TextBox1.Text & "','" & DateTimePicker1.Text & "','" & DateTimePicker2.Text & "',1)"

But it doesnt work....it gives an exception saying
Cast from type 'DataRowView' to type 'String' is not valid

Please help...
thanks
 
Komalj said:
Hi
I have a table in MS Access....that contains fields
ID (number)
Name (Text)
Date_Issue (Date)
Date_Return (date)
Flag (Yes/No)

Now in my windows from i have a combobox, testbox, listbox and datepicker.

I want to insert values from these controls to my table....

I m using the following syntax
"INSERT INTO Table(ID,Name,Date_of_Issue,Date_of_Return,Flag) Values (" & ListBox1.SelectedValue & ",'" & TextBox1.Text & "','" & DateTimePicker1.Text & "','" & DateTimePicker2.Text & "',1)"

But it doesnt work....it gives an exception saying
Cast from type 'DataRowView' to type 'String' is not valid

Please help...
thanks
why wont you use a parameters in doing that thing?
 
Hi dears
I make a table (member) in access which have column(codeno,memberid,employeeid,name,phone,designation).Now i also make a form in vb.net for this.and draw textbox for code,name,phone and designation,and for employeeid and memberid i draw comobox from which i select one.Now the problem is How i insert the value in this R How i write a code for this.pls pls if anyone have idea i appreciate him but reply as soon as possible.
tanx bye
 
what do you mean by R in your statement?
to save the value from your textboxes and combobox make use ExecuteNonQuery.
 
Back
Top