By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

DataAdapter posts "0.0" to DB when Param contains System.DbNull

P: n/a
I'm having some trouble with the DataAdapter in my code. When the parameter
in an OleDbCommand, which is created
as having a type of OleDbType.Decimal, is set to System.DbNull, the actual
value posted to the database upon execution of the Insert command is a
floating point value of zero (0.0, actually).

The DataAdapter is associated with a DataGrid. When a row is inserted into
the grid, the column may contain either nothing "(null)"
or a floating point value.

Here's some excerpts from the code that may help someone help me with this:

DAdapter = New OleDbDataAdapter

'Build insert command
CommandText = "Insert into db.threshold threshd_critical) values (?)"
DAdapter.InsertCommand = New OleDbCommand(CommandText, mConnection)

'Define parameters for insert command
workParam = DAdapter.InsertCommand.Parameters.Add("threshd_cri tical",
OleDbType.Decimal)
workParam.SourceColumn = "threshd_critical"
workParam.SourceVersion = DataRowVersion.Current

Any assistance would be greatly appreciated!

Tom
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Tom,

Several issues can exhibit this symptom. Would you please let me know what
database you're using (I'm assuming it's Microsoft Access, since you're
using OleDb), and we can narrow down the issue. This may not be an issue
with the DataAdapter (I assume you've tested this with a straight SQL
statement in your database's UI?).

HTH,
Derrick
"Tom Luetz II" <tl****@comcast.net> wrote in message
news:qP********************@comcast.com...
I'm having some trouble with the DataAdapter in my code. When the parameter in an OleDbCommand, which is created
as having a type of OleDbType.Decimal, is set to System.DbNull, the actual
value posted to the database upon execution of the Insert command is a
floating point value of zero (0.0, actually).

The DataAdapter is associated with a DataGrid. When a row is inserted into
the grid, the column may contain either nothing "(null)"
or a floating point value.

Here's some excerpts from the code that may help someone help me with this:
DAdapter = New OleDbDataAdapter

'Build insert command
CommandText = "Insert into db.threshold threshd_critical) values (?)"
DAdapter.InsertCommand = New OleDbCommand(CommandText, mConnection)

'Define parameters for insert command
workParam = DAdapter.InsertCommand.Parameters.Add("threshd_cri tical",
OleDbType.Decimal)
workParam.SourceColumn = "threshd_critical"
workParam.SourceVersion = DataRowVersion.Current

Any assistance would be greatly appreciated!

Tom

Nov 20 '05 #2

P: n/a
The database being used is IBM UDB DB2 v7.2.

If you execute the SQL manually, the proper value is inserted into the
database.

I should have mentioned that my code worked just fine when the
InsertCommand's
parameter was defined as OleDbType.Integer; only when it was changed to
Decimal
did I start to have the aforementioned problem.

Thanks,
Tom

"Derrick [MCSD]" <Derrick[underscore]Repep[at]toxicall[dot]com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Tom,

Several issues can exhibit this symptom. Would you please let me know what database you're using (I'm assuming it's Microsoft Access, since you're
using OleDb), and we can narrow down the issue. This may not be an issue
with the DataAdapter (I assume you've tested this with a straight SQL
statement in your database's UI?).

HTH,
Derrick
"Tom Luetz II" <tl****@comcast.net> wrote in message
news:qP********************@comcast.com...
I'm having some trouble with the DataAdapter in my code. When the

parameter
in an OleDbCommand, which is created
as having a type of OleDbType.Decimal, is set to System.DbNull, the actual value posted to the database upon execution of the Insert command is a
floating point value of zero (0.0, actually).

The DataAdapter is associated with a DataGrid. When a row is inserted into the grid, the column may contain either nothing "(null)"
or a floating point value.

Here's some excerpts from the code that may help someone help me with

this:

DAdapter = New OleDbDataAdapter

'Build insert command
CommandText = "Insert into db.threshold threshd_critical) values (?)"
DAdapter.InsertCommand = New OleDbCommand(CommandText, mConnection)

'Define parameters for insert command
workParam = DAdapter.InsertCommand.Parameters.Add("threshd_cri tical",
OleDbType.Decimal)
workParam.SourceColumn = "threshd_critical"
workParam.SourceVersion = DataRowVersion.Current

Any assistance would be greatly appreciated!

Tom


Nov 20 '05 #3

P: n/a

The database being used is IBM UDB DB2 v7.2.

If you execute the SQL manually, the proper value is inserted into the
database.

I should have mentioned that my code worked just fine when the
InsertCommand's
parameter was defined as OleDbType.Integer; only when it was changed to
Decimal
did I start to have the aforementioned problem.

Thanks,
Tom
"Derrick [MCSD]" <Derrick[underscore]Repep[at]toxicall[dot]com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Tom,

Several issues can exhibit this symptom. Would you please let me know

what
database you're using (I'm assuming it's Microsoft Access, since you're
using OleDb), and we can narrow down the issue. This may not be an issue
with the DataAdapter (I assume you've tested this with a straight SQL
statement in your database's UI?).

HTH,
Derrick
"Tom Luetz II" <tl****@comcast.net> wrote in message
news:qP********************@comcast.com...
I'm having some trouble with the DataAdapter in my code. When the

parameter
in an OleDbCommand, which is created
as having a type of OleDbType.Decimal, is set to System.DbNull, the

actual value posted to the database upon execution of the Insert command is a
floating point value of zero (0.0, actually).

The DataAdapter is associated with a DataGrid. When a row is inserted into the grid, the column may contain either nothing "(null)"
or a floating point value.

Here's some excerpts from the code that may help someone help me with

this:

DAdapter = New OleDbDataAdapter

'Build insert command
CommandText = "Insert into db.threshold threshd_critical) values (?)"
DAdapter.InsertCommand = New OleDbCommand(CommandText, mConnection)

'Define parameters for insert command
workParam = DAdapter.InsertCommand.Parameters.Add("threshd_cri tical",
OleDbType.Decimal)
workParam.SourceColumn = "threshd_critical"
workParam.SourceVersion = DataRowVersion.Current

Any assistance would be greatly appreciated!

Tom



Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.