-
June 3rd, 2013, 07:07 PM
#1
How To Save Data From DataGridView bound to one datasource to aTableadapter
I have a dataGridView that is bound to a DataTable and I am trying to save the data to a TableAdapter.
This is a VS 2008 C# Windows Application.
I know that I am casting this correctly as I am raising the following error:
Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'MFG_CAPTURE_DATADataTable'.
Here is the call that is raising the error:
myST_BLL.captureDataTableAdapter().Update((dsStagingTables.MFG_CAPTURE_DATADataTable)dvgDataCapture.DataSource);
Here is the method itself in the myST_BLL class:
static private MFG_CAPTURE_DATATableAdapter _captureDataTableAdapter;
public MFG_CAPTURE_DATATableAdapter captureDataTableAdapter()
{
if (_captureDataTableAdapter == null)
{
_captureDataTableAdapter = new MFG_CAPTURE_DATATableAdapter();
_captureDataTableAdapter.Connection.ConnectionString = _connStr;
}
return _captureDataTableAdapter;
}
The DataTable is one that I have created by combining two tables but the format is identical to the table that the MFG_CAPTURE_DATATableAdapter is connected to.
Can someone give me a little guidance please?
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|