What wrong my Updating Northwind Syntax Win[C#]

  • Thread starter Thread starter MikeY
  • Start date Start date
M

MikeY

Hi Everyone,

I'm having problems with my syntax on the updating part for the
Northwind.MDB. All other code seems fine. It has to do with the Order
Details on the thisAdapter.Update( ). Or I believe the problem lies with
with space between Order and Details and not knowing how to get around that
problem. I would like to keep with the space being left in-between the two
names. My Code is as follows:

Any and all help is appreciated.
Mike





private void DataUpdate()
{

try

{

OleDbConnection thisConnection = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Northwind.MDB");



thisConnection.Open();


OleDbDataAdapter thisAdapter = new OleDbDataAdapter("SELECT * FROM [Order
Details]", thisConnection);
OleDbCommandBuilder thisBuilder = new OleDbCommandBuilder(thisAdapter);



DataSet thisDataSet = new DataSet();

thisAdapter.Fill(thisDataSet, "Order Details");
thisDataSet.Tables["Order Details"].Rows[0]["Quantity"] = "99";


thisAdapter.Update(thisDataSet, "[Order Details]");
thisConnection.Close();

}
catch(Exception myExcept)
{

MessageBox.Show(myExcept.Message);
}

}
 
What is your error? But beware [Orders] and [Order Details] so you should
have 2 sqltableadapter. If you are dragging the data from your dataset to
form then you need to add one of the update by your own, it will not be
generated. Good luck.

chanmm
 
Hi Chanmm,

The error that it is triggering is "Update unable to find TableMapping
['[Order Details]'] or Data Table '[Order Details]'. Order Details is just
one table.

Thanks
Mike Y

chanmm said:
What is your error? But beware [Orders] and [Order Details] so you should
have 2 sqltableadapter. If you are dragging the data from your dataset to
form then you need to add one of the update by your own, it will not be
generated. Good luck.

chanmm

MikeY said:
Hi Everyone,

I'm having problems with my syntax on the updating part for the
Northwind.MDB. All other code seems fine. It has to do with the Order
Details on the thisAdapter.Update( ). Or I believe the problem lies with
with space between Order and Details and not knowing how to get around
that problem. I would like to keep with the space being left in-between
the two names. My Code is as follows:

Any and all help is appreciated.
Mike





private void DataUpdate()
{

try

{

OleDbConnection thisConnection = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Northwind.MDB");



thisConnection.Open();


OleDbDataAdapter thisAdapter = new OleDbDataAdapter("SELECT * FROM [Order
Details]", thisConnection);
OleDbCommandBuilder thisBuilder = new OleDbCommandBuilder(thisAdapter);



DataSet thisDataSet = new DataSet();

thisAdapter.Fill(thisDataSet, "Order Details"); thisDataSet.Tables["Order
Details"].Rows[0]["Quantity"] = "99";


thisAdapter.Update(thisDataSet, "[Order Details]");
thisConnection.Close();

}
catch(Exception myExcept)
{

MessageBox.Show(myExcept.Message);
}

}
 
Back
Top