Visual2013 error when trying to update data to SQL (System.InvalidOperationException) - sql

enter image description here
Everytime im trying to update data i get this:
Unhandled exception of type 'System.InvalidOperationException' in
WindowsApplication2.exe Additional information: Update requires a
valid UpdateCommand when passing a DataRow collection with changed row
I even recreated table and form in MS visual and nothing happened

Related

Access VB.net DataGridView== > Error Message : "No value given for one or more required parameters."

my VB programm works fine, then I had to add 4 new boolean fields to a table in Access2010.
I updated the datasource and the preview of the dataview works fine (Visual Studio 2019).
But unfortunately my DataGridView doesn't work anymore.
I deleted the DataGridView and created a new one with the ame name but it doesn't help.
I still the message : "No value given for one or more required parameters."
What can I do ? I checked the columns name and everything is ok ?

DataSet1>DataTable1 strange error

I created a dataset and added so a datatable with about 18 columns.
I added the datagrid and the data details on the form. Compiler show no errors.
When i run the application i get this strange error that i'm not understanding! Code show no error too, what's wrong with this table?
An unhandled exception of type 'System.ArgumentException' in
System.Windows.Forms.dll
Additional Information: Unable to bind to
property or column Date of DataSource.
Edit: error came out when i add the datatable1 details to the form. datagridview instead give no problem
Please someone could give me tips to avoid this error. I have no idea, i found nothing on google.
screenshot:

GridView does not update DataTable

I am using a DevExpress XtraGrid/View for windows forms. The datasource of the grid is a binding source, which is connected to a dataset. My problem is, this table adapter does not update the datatable. I can insert new rows without problems, but I can't update. No error message is thrown; when I save changes, the row value just reverts. This happens for every column in the row. Here is my code for saving and then reloading data:
' Class variable
Private _invoiceDetailsAdapter As dsInvoiceDetailsTableAdapters.inv_InvoiceDetailsTableAdapter = New dsInvoiceDetailsTableAdapters.inv_InvoiceDetailsTableAdapter()
'Save Data
InvInvoiceLineBindingSource.EndEdit()
_invoiceDetailsAdapter.Update(DsInvoiceDetails.inv_InvoiceDetails)
'Load
DsInvoiceDetails.inv_InvoiceDetails.Clear()
If Me._invoiceId > 0 Then
_invoiceDetailsAdapter.Fill(DsInvoiceDetails.inv_InvoiceDetails, _invoiceId)
InvInvoiceLineBindingSource.Sort = "LineNum"
End If
I've figured out that it must be the dataset itself, because I've tried using a regular DataGridView with the dataset, to no avail. I generated the dataset through the wizard and had to add ColumnName and SourceColumn properties in the parameters for Insert & Update. The parameters for Insert & Update look identical as far as properties are concerned.
I've also tried creating new datasets, datatables, binding sources and tableadapters. I've even tried a DataAdapter but there was no difference. I have literally spent 2 weeks now looking through the properties and debugging, trying to find a cause.
Can someone please offer some advice?
The problem was DevExpress' XtraGrid functionality.
The XtraGrid does not immediately save an edit value to the linked dataset. The modified row is usually posted to the data object when focus is moved to another grid row. You can programmatically force the update by calling the UpdateCurrentRow method. In your case you should only call the CloseEditor and UpdateCurrentRow methods before updating the dataset via the DB adapter object.
So if a user only updates only one row, those changes go nowhere. Read on for a code snippet...
http://www.devexpress.com/Support/Center/Question/Details/A327

Loading data into a datagridviewcomboboxcolumn

I have a datagridviewcomboxcolumn to which I need to load data either from another form or by excel.
Before loading, I am validating the data to make sure it exists in the datagridviewcomboxcolumn list.
Whenever I try to load the data, it gives an exception error as value is not valid.
How can this be solved?
Or
is there a workaround to disable this error?

Add values to listbox from dataset - NullReferenceException error (VB.NET)

I'm trying to populate a single record from a dataset into a listbox. I can see that the dataset is populated with the expected value with the column header "PLI" in the dataset visualizer. I've tried to use the following command to populate the listbox with the value in the dataset:
lstExistingPLI.Items.Add(New ListItem(ds.Tables("PLI").ToString()))
I keep getting an unhandled NullReferenceException error. I've also tried using
lstExistingPLI.Items.Add(ds.Tables("PLI").ToString())
and getting the same error. Can anyone help me out with what I'm doing wrong? Thanks!
First i must admit that i don't know what causes your NullRefernceException.
Your ListBox lstExistingPLI might be null if you haven't initialized it. The DataSet ds might be null if it was not initialized. Maybe you have initialized it but you haven't added a DataTable with name "PLI" to it, then null would be returned from the DataTableCollection.Item property.
However, ds.Tables returns a DataTable. Why do you think that DataTable.ToString returns anything that could be added to a ListBox in a useful way? Do you want to add the fields of every DataRow?
(assuming that all is initialized correctly)
For Each row As DataRow In ds.Tables(0).Rows
'assuming that PLI is not the table but the field that you want to add to the ListBox'
lstExistingPLI.Items.Add(New ListItem(row.Field(Of String)("PLI")))
Next