Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > insert problem in datagrid view
 

insert problem in datagrid view

Dim rowitem As DataRow = ds.Tables(tbale).NewRow

rowitem(

"Id") = DbAccess.executeScalarQuery("Select isnull(Max(id),0)+1 from Supplier")

rowitem(

"Sname") = txtname.Text

rowitem("IDate") = Format(DateTime.Now, "U")

rowitem(

"Dbit") = 0

ds.Tables(tbale).Rows.Add(rowitem)

DbAccess.executeUpdateDataSet(ds, tbale,

"select * from Supplier") 'Call command builder

ds.Tables(tbale).AcceptChanges()

DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.Rows(DataGridView1.Rows.Count - 1).Index

DtgvSupplier.Refresh()

DataGridView1.Rows(DataGridView1.Rows.Count - 1).Selected =

True

DataGridView1.CurrentCell = DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(1)




sir ,when i insert row in datagridview ,row insert successfully but problem is,previous row which is last time selected,show me same data as inserted row .when i close the form
then their is no problem ,data is correct,database is also correct,
(but whenever iinsert therow and previous selected row show me same data although dataset and database do not change)

M.saqib  Wednesday, September 02, 2009 1:48 PM

Hi,

I have read your code. It seems correct. You have set the rowitem value and add the rowitem to the datatable.

I suggest you to set breakpoints at

->ds.Tables(tbale).Rows.Add(rowitem)

->DbAccess.executeUpdateDataSet(ds, tbale,"select * from Supplier") 'Call command builder

And check

1. The table has added a rowitem and the value is correct.

2. DbAccess.executeUpdateDataSet method is run correctly.


Please let me know the result. You can also make a demo project for us to test. Upload your demo project to some server and offer us the URL. Skydrive (http://skydrive.live.com/) may be a good option to upload the demo.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Sunday, September 06, 2009 2:51 PM

We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Thursday, September 10, 2009 3:05 AM
hi
i upload demo project,Please check it
M.saqib  Saturday, September 12, 2009 11:06 AM

Could you please offer us the download link?

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Sunday, September 13, 2009 9:34 AM
http://skydrive.live.com/,

i upload the demo code in your side,please check it out
M.saqib  Sunday, September 13, 2009 3:05 PM

You can use google to search for other answers

Custom Search

More Threads

• SQL DataAdapter.Update(Dataset) Method is not working
• treeview with custom checkbox
• Force Databinding before the control gets into view
• Datagrid columns do not reflect column changes to database table.
• Pressing Escape in a DataViewGrid throws an 'System.NullReferenceException'
• Designer Error when setting BindingSource.Datasource = SomeOtherBindingSource
• Totals...
• DataGridViewComboBoxColumn
• DataGrid From 2 Tables but cannot bind second table to
• DataGridView Problems Adding New Row