oledbParameter has no default value

M

Marco Martin

Hi,

I've got an oledb parameter that I'm sending to an Access DB.
The table I'm sending it to has a column called "Zone" of type String that
has a default value of "".

So I create the parameter with its name and dbType, and add it to an
Insertcommand.
I then set the Command.Text value.

Sample code goes like this;
....
OleDBParameter prmZone = new OleDBParameter("Zone", OleDbType.VarChar);
prmZone.SourceColumn = myDataSet.tblRecords.ZoneColumn;//Using a typed
dataset
cmdInsert.Parameters.Add(prmZone);
cmdInsert.CommandText = "INSERT INTO tblRecords VALUES(ID, Zone...)";

RecordsAdapter.InsertCommand = cmdInsert;

RecordsAdapter.Update(myDataSet, "tblRecords");

When I run this code, I get a run-time error "Parameter Zone has no default
value".

If my table has a default value, and the parameter gets assigned a value
from the dataset (I checked and there are no blank fields), why would I get
this error?

Any thoughts would be appreciated.

Regards,

Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top