|
Hi I have a windows form project with a rental form . On this form is two fillby texboxes with whichi fill customer and dvd textboxes from the customer and dvd tables.I want to fill a datagridview with up to three rentals and then update the customer rental table with the new records in the datagridview.The rentals table also have a autoincrement primary key id column. i'm stuck with the part where the datagrid gets filled from the textboxes.as well as how to insert the new records into the customer rental table. I need help |
| stephanusdp Monday, July 27, 2009 7:14 PM |
Hi stephanusdp, Update unbound data in a DataGridView, you need to generate sql by yourself. You can put a loop to all the rows in DataGridView, get the value from cell and create sql script(insert/update table). Then use SqlCommand to run the command. SqlCommand.ExecuteNonQuery Method http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery.aspx Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer bystephanusdp Thursday, July 30, 2009 8:33 PM
-
|
| Kira Qian Wednesday, July 29, 2009 8:37 AM |
First, which language are you using? Which version of the .NET Framework? Are you using databinding? If so, which kind? If I understand the question correctly, you can retrieve the data from the table to populate the TextBoxes, but you don't know how to retrieve the data from the table to populate the DataGridView? Could you post the code you are using to populate the TextBoxes? www.insteptech.com ;
msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS! |
| DeborahK Monday, July 27, 2009 7:52 PM |
Thanks for replying so fast . I use the fillby method to input a Customer Id and then his name surname phone number is diplayed in bounded textboxes . This data is obtained from the Customers table.Then on the same form i use the fillby method to enter a DvD id and dvd name actor daily rental price ect is displayed in bouded textboxes on the form.datavalidation is done here looking if customer exist , dvd is available ext,This is easy . I don't know if i'm on the right track , but i then have abounded datagridview to display the customer rental info , like cust_id , Dvd_id Cost, rent_date and a column for the primary key Customer_rental_id which autoincrement the rental date is obtained form the value of a textbox showing current time. how do i get the values from the textboxes into a bounded datagridview . i know how to do this with unbounded datagridview . Am i on the right track im using vs2008 for this project. |
| stephanusdp Monday, July 27, 2009 8:18 PM |
sorry i did not see the first part of your question.vb.net and 3.5 |
| stephanusdp Monday, July 27, 2009 8:20 PM |
It sounds like you are using TableAdapters and their FillBy method? I have not used those so am not that familar with them. I assumed you could associate a DataGridView with a FillBy as well. www.insteptech.com ;
msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS! |
| DeborahK Monday, July 27, 2009 8:23 PM |
Yes that is correct. I know how to fill the datgridview with existing data but i am struggling with entering new records into the datagridview and then updating the customer_rental _table with this record. I use information from three different related tables to get one new record in the customer_rental_table.
Is there a way to update a table from an unbounded datagridview?? This seems the logical way forward? |
| stephanusdp Monday, July 27, 2009 8:28 PM |
Hi stephanusdp, Update unbound data in a DataGridView, you need to generate sql by yourself. You can put a loop to all the rows in DataGridView, get the value from cell and create sql script(insert/update table). Then use SqlCommand to run the command. SqlCommand.ExecuteNonQuery Method http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery.aspx Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer bystephanusdp Thursday, July 30, 2009 8:33 PM
-
|
| Kira Qian Wednesday, July 29, 2009 8:37 AM |