Trouble updating to Access database

  • Thread starter Thread starter Jason Yau
  • Start date Start date
J

Jason Yau

I'm having trouble trying to update an Access database
file. I get the following error:

************** Exception Text **************
System.Data.OleDb.OleDbException: Parameter ?_92 has no
default value.
at System.Data.Common.DbDataAdapter.Update(DataRow[]
dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet
dataSet, String srcTable)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet)
,etc.

My database has 89 fields, of which the 89th is an
autonumber, primary key, indexed no-duplicate field. I
don't understand why it's giving an error about parameter
92. I have no trouble selecting the data and putting it
into a Dataset/Dataview and editing with a DataGrid, but
when I run the following code, I get the error above.

oleDbDataAdapter1.Update(dataSet1);

Any help here would be much appreciated.

Jason
 
Hi Jason,

I guess we have to see the code behind oleDbDataAdapter1...
One of its command has a parameter named ?_92 that gets no value when doing
update and it is also not nullable.
 
The code is very simple:

private void button1_Click(object sender, System.EventArgs e)
{
oleDbDataAdapter1.Fill(dataSet1, "measurerData");
dataView1.Table = dataSet1.Tables[0];
}

private void button2_Click(object sender, System.EventArgs e)
{
oleDbDataAdapter1.Update(dataSet1);
}

Button1 is a button I am using to connect to the database
and populate the datagrid, and button2 is the button I am
using to save the changes to the database.

I simply used the OleDbDataAdapter control from the Data
toolbox and dragged it to the form, letting it generate (it
claimed successfully) the SELECT, UPDATE, DELETE, and
INSERT statements for me, based on the database schema.
Again, the connect button works fine in getting data out of
the database and showing it in a DataGrid
(dataGrid1.DataSource=dataView1).

Is there something I'm missing?

Jason
-----Original Message-----
Hi Jason,

I guess we have to see the code behind oleDbDataAdapter1...
One of its command has a parameter named ?_92 that gets no value when doing
update and it is also not nullable.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

I'm having trouble trying to update an Access database
file. I get the following error:

************** Exception Text **************
System.Data.OleDb.OleDbException: Parameter ?_92 has no
default value.
at System.Data.Common.DbDataAdapter.Update(DataRow[]
dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet
dataSet, String srcTable)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet)
,etc.

My database has 89 fields, of which the 89th is an
autonumber, primary key, indexed no-duplicate field. I
don't understand why it's giving an error about parameter
92. I have no trouble selecting the data and putting it
into a Dataset/Dataview and editing with a DataGrid, but
when I run the following code, I get the error above.

oleDbDataAdapter1.Update(dataSet1);

Any help here would be much appreciated.

Jason


.
 
Hi,

The code is very simple:

private void button1_Click(object sender, System.EventArgs e)
{
oleDbDataAdapter1.Fill(dataSet1, "measurerData");
dataView1.Table = dataSet1.Tables[0];
}

private void button2_Click(object sender, System.EventArgs e)
{
oleDbDataAdapter1.Update(dataSet1);
}

Button1 is a button I am using to connect to the database
and populate the datagrid, and button2 is the button I am
using to save the changes to the database.

I simply used the OleDbDataAdapter control from the Data
toolbox and dragged it to the form, letting it generate (it
claimed successfully) the SELECT, UPDATE, DELETE, and
INSERT statements for me, based on the database schema.
Again, the connect button works fine in getting data out of
the database and showing it in a DataGrid
(dataGrid1.DataSource=dataView1).

Is there something I'm missing?

CommandBuild wizard has problems when there are many columns...
I suggest you to take a look at
Windows Form Designer generated code region

to see what is going behind the update.
 
Back
Top