Hi thanks for the reply,
I believe its both. Here is my code which I cannot get to update, it throws
the error: "No value given for one or more required parameters"
------------------Code start------------------------------
private void OpenDataset()
{
//Connection string
string connection = @"Provider=Microsoft.Jet.OLEDB.4.0; "+
@"Data Source=C:\stock.mdb";
// Setup DB-Connection
OleDbConnection conn = new OleDbConnection(connection);
//SQL Select string
//string query = "SELECT * FROM [Component-Codes]";
// Fill the Dataset with Compnent details, map Default Tablename
// "Table" to "Components".
adapter = new OleDbDataAdapter("SELECT * FROM [Component-Codes]",conn);
adapter.TableMappings.Add("Table","Components");
adapter.Fill(dset);
// Fill the Dataset with Compnent details, map Default Tablename
// "Table" to "Products".
adapter2 = new OleDbDataAdapter("SELECT * FROM [Product-Codes]",conn);
adapter2.TableMappings.Add("Table","Products");
adapter2.Fill(dset);
// Fill the Dataset with Compnent details, map Default Tablename
// "Table" to "components".
adapter3 = new OleDbDataAdapter("SELECT * FROM
[Product-Component-Junction]",conn);
//---------------Test area------------------------
adapter3.UpdateCommand = new OleDbCommand("UPDATE
[Product-Component-Junction] SET Quantity = ? " +
"WHERE [Component-Code] = ? AND [Product-Code] = ?" , conn);
//Add Parameters and set values.
//adapter3.UpdateCommand.Parameters.Add("@Country",OleDbType.VarChar,
15).Value = "UK";
//selectCMD.Parameters.Add("@Country", OdbcType.VarChar, 15).Value =
"UK";
//selectCMD.Parameters.Add("@City", OdbcType.VarChar, 15).Value =
"London";
//adapter3.UpdateCommand = new OleDbCommand("UPDATE
[Product-Component-Junction] SET Quantity = ? " , conn);
//---------------Test area------------------------
adapter3.TableMappings.Add("Table","prod-comp-junction");
adapter3.Fill(dset);
// Establish the Relationship "ProdComp"
// between Products ---< prod-comp-junction
System.Data.DataRelation ProdComp;
System.Data.DataColumn col_Products;
System.Data.DataColumn col_JunctionTable_Prods;
col_Products = dset.Tables["Products"].Columns["Code"];
col_JunctionTable_Prods =
dset.Tables["prod-comp-junction"].Columns["Product-Code"];
ProdComp = new System.Data.DataRelation("ProdComp",col_Products,
col_JunctionTable_Prods);
dset.Relations.Add(ProdComp);
// Establish the Relationship "ProdComp"
// between Components ---< prod-comp-junction
System.Data.DataRelation Component_Product_Junction;
System.Data.DataColumn col_Components;
System.Data.DataColumn col_JunctionTable;
col_Components = dset.Tables["Components"].Columns["Code"];
col_JunctionTable =
dset.Tables["prod-comp-junction"].Columns["Component-Code"];
Component_Product_Junction = new
System.Data.DataRelation("Component_Product_Junction",col_Components,col_JunctionTable);
dset.Relations.Add(Component_Product_Junction);
dsView = dset.DefaultViewManager;
// Grid Databinding
dataGrid1.DataSource = dsView;
dataGrid1.DataMember = "Products.ProdComp";
//--------------------Combobox---------------
comboBox1.DataSource = dset.Tables["Products"];
comboBox1.DisplayMember = "Code";
comboBox1.ValueMember = "Products.Code";
//--------------------Combobox---------------
}
private void openDataSet()
{
string connection = @"Provider=Microsoft.Jet.OLEDB.4.0; "+
@"Data Source=C:stock.mdb";
string query = "SELECT * FROM [Component-Codes]";
OleDbConnection conn = new OleDbConnection(connection);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(query, conn);
adapter.Fill(dset);
}
private void BindControls()
{
comboBox1.DataSource = dset.Tables["Table"];
comboBox1.DisplayMember = "Code";
}
private void comboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dsView,"Products"];
cm.Position = comboBox1.SelectedIndex;
}
private void comboBox1_BindingContextChanged(object sender, EventArgs e)
{
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dset,"Products"];
cm.Position = cm.Count + 1;
}
private void btnUpdate_Click(object sender, System.EventArgs e)
{
try
{
//adapter.Update(dset);
//adapter2.Update(dset);
adapter3.Update(dset);
}
catch(Exception exc)
{
catchError(exc);
}
}
-----------------------Code end-----------------------------------