473,472 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dataadaptor.update problem

My app is throwing an exception regarding trying to post a null to a
required field. Examining the datarow in question, I see a valid date
value. The row's state is "added"

I'm relying on an oledbcommandbuilder to supply the missing insert or
update commands. The following shows how I'm creating my components:

Private mdaCertByID As New OleDbDataAdapter 'selects a single cert by ID.
....
mdaCertByID.SelectCommand = New OleDbCommand
With mdaCertByID.SelectCommand
.Connection = NewCnnData()
.CommandType = CommandType.Text
.CommandText = "select * from Cert where id=@certid"
.Parameters.Add("@certid", OleDbType.Integer)
End With
mcbCertByID = New OleDbCommandBuilder(mdaCertByID)

Here's where I execute the update:

Public Function updatePanTixRow() As Boolean
Dim r As DataRow
Dim n As IntegerAddHandler mdaCertByID.RowUpdated, New
OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
Try
If Not dsData.HasErrors Then
n = mdaCertByID.Update(dsData, "cert")
updatePanTixRow = True
Else
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox("Row " + r.Item("id") + _
" of " + dsData.Tables("cert").Rows.Count.ToString + " rows: " +
r.RowError)
End If
Next
updatePanTixRow = False
End If
'Debug.WriteLine(mcbCertByID.GetUpdateCommand.Comm andText)
Catch ex As Exception
updatePanTixRow = False
Debug.WriteLine(mcbCertByID.GetInsertCommand.Comma ndText)
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox(r.RowError)
r.RowError = ""
Else
MsgBox(ex.Message)
End If
Next
End Try
End Function
Nov 21 '05 #1
4 1836
You're positive that the value is in fact there for every row? I've run
across a similar problem before and found that one of the last rows was the
culprit but i was checking the first 10 for instance which all had values.

The quick way to verify is to set a Default value for the DataColumn with a
good date (it probably won't be the real date you want, but for testing
it'll suit your needs). After you have a default value, hit update and see
if it still blows up.

If this isn't the problem,, then look at the column mapping w/ your dataset
and make sure the fields are mapped correctly, and verify the update command
that your commandbuilder is building. It' hard to tell right now without
knowing a little more... if you can narrow down the row (unless it's
happening to all of them) this would be helpful too.

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Jeremy" <je****@ninprodata.com> wrote in message
news:uF*************@TK2MSFTNGP15.phx.gbl...
My app is throwing an exception regarding trying to post a null to a
required field. Examining the datarow in question, I see a valid date
value. The row's state is "added"

I'm relying on an oledbcommandbuilder to supply the missing insert or
update commands. The following shows how I'm creating my components:

Private mdaCertByID As New OleDbDataAdapter 'selects a single cert by ID.
...
mdaCertByID.SelectCommand = New OleDbCommand
With mdaCertByID.SelectCommand
.Connection = NewCnnData()
.CommandType = CommandType.Text
.CommandText = "select * from Cert where id=@certid"
.Parameters.Add("@certid", OleDbType.Integer)
End With
mcbCertByID = New OleDbCommandBuilder(mdaCertByID)

Here's where I execute the update:

Public Function updatePanTixRow() As Boolean
Dim r As DataRow
Dim n As IntegerAddHandler mdaCertByID.RowUpdated, New
OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
Try
If Not dsData.HasErrors Then
n = mdaCertByID.Update(dsData, "cert")
updatePanTixRow = True
Else
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox("Row " + r.Item("id") + _
" of " + dsData.Tables("cert").Rows.Count.ToString + " rows: " +
r.RowError)
End If
Next
updatePanTixRow = False
End If
'Debug.WriteLine(mcbCertByID.GetUpdateCommand.Comm andText)
Catch ex As Exception
updatePanTixRow = False
Debug.WriteLine(mcbCertByID.GetInsertCommand.Comma ndText)
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox(r.RowError)
r.RowError = ""
Else
MsgBox(ex.Message)
End If
Next
End Try
End Function

Nov 21 '05 #2
Thanks, I really appreciate whatever thoughts you have.

Rowcount is 1, so I think I can conclusively say that all rows have a valid
value for this column. There are 2 tables in the dataset, with very
different names, neither of them the default. The error message is quite
clear on which table is the problem (I thought the pgm might somehow be
trying to update a wrong table somehow).

I'm not using the gui to hold my dataset, so the column mappings should be
computed based on the select statement, right? That is "select * where
id=@certid". I was thinking about looking at the dataset parameters
(probably the wrong term, but whatever thing the dataset uses to keep the
original value, the changed value, etc), but haven't figured out how to view
them yet.

The field in question does have a default value of date() (did I mention
this is MS Access?). Also, the field is actually the 2nd one
(left-to-right) that is required. The previous one is an int, and has a
default of 0.

Jeremy

"W.G. Ryan eMVP" <Wi*********@NoSpam.gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You're positive that the value is in fact there for every row? I've run
across a similar problem before and found that one of the last rows was
the
culprit but i was checking the first 10 for instance which all had values.

The quick way to verify is to set a Default value for the DataColumn with
a
good date (it probably won't be the real date you want, but for testing
it'll suit your needs). After you have a default value, hit update and
see
if it still blows up.

If this isn't the problem,, then look at the column mapping w/ your
dataset
and make sure the fields are mapped correctly, and verify the update
command
that your commandbuilder is building. It' hard to tell right now without
knowing a little more... if you can narrow down the row (unless it's
happening to all of them) this would be helpful too.

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Jeremy" <je****@ninprodata.com> wrote in message
news:uF*************@TK2MSFTNGP15.phx.gbl...
My app is throwing an exception regarding trying to post a null to a
required field. Examining the datarow in question, I see a valid date
value. The row's state is "added"

I'm relying on an oledbcommandbuilder to supply the missing insert or
update commands. The following shows how I'm creating my components:

Private mdaCertByID As New OleDbDataAdapter 'selects a single cert by ID.
...
mdaCertByID.SelectCommand = New OleDbCommand
With mdaCertByID.SelectCommand
.Connection = NewCnnData()
.CommandType = CommandType.Text
.CommandText = "select * from Cert where id=@certid"
.Parameters.Add("@certid", OleDbType.Integer)
End With
mcbCertByID = New OleDbCommandBuilder(mdaCertByID)

Here's where I execute the update:

Public Function updatePanTixRow() As Boolean
Dim r As DataRow
Dim n As IntegerAddHandler mdaCertByID.RowUpdated, New
OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
Try
If Not dsData.HasErrors Then
n = mdaCertByID.Update(dsData, "cert")
updatePanTixRow = True
Else
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox("Row " + r.Item("id") + _
" of " + dsData.Tables("cert").Rows.Count.ToString + " rows: "
+
r.RowError)
End If
Next
updatePanTixRow = False
End If
'Debug.WriteLine(mcbCertByID.GetUpdateCommand.Comm andText)
Catch ex As Exception
updatePanTixRow = False
Debug.WriteLine(mcbCertByID.GetInsertCommand.Comma ndText)
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox(r.RowError)
r.RowError = ""
Else
MsgBox(ex.Message)
End If
Next
End Try
End Function


Nov 21 '05 #3
Here is what VS says about the column in question. Curiously, the
fillschema did not apparently get all the answers right. Notice that
default value is {System.DBNull}, and AllowDBNull is True, contrary to
actual settings in the database (yes, I did triple check the path and
connection string). But aside from that, I don't know what this tells me.
Can anyone shed light?

? mdsdata.Tables("cert").Columns(6)
{System.Data.DataColumn}
AllowDBNull: True
AutoIncrement: False
AutoIncrementSeed: 0
AutoIncrementStep: 1
Caption: "DateofInspection"
ColumnMapping: Element
ColumnName: "DateofInspection"
Container: Nothing
DataType: {System.RuntimeType}
DefaultValue: {System.DBNull}
DesignMode: False
Expression: ""
ExtendedProperties: {System.Data.PropertyCollection}
MaxLength: -1
Namespace: ""
Ordinal: 6
Prefix: ""
ReadOnly: False
Site: Nothing
Table: {System.Data.DataTable}
Unique: False
"W.G. Ryan eMVP" <Wi*********@NoSpam.gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You're positive that the value is in fact there for every row? I've run
across a similar problem before and found that one of the last rows was
the
culprit but i was checking the first 10 for instance which all had values.

The quick way to verify is to set a Default value for the DataColumn with
a
good date (it probably won't be the real date you want, but for testing
it'll suit your needs). After you have a default value, hit update and
see
if it still blows up.

If this isn't the problem,, then look at the column mapping w/ your
dataset
and make sure the fields are mapped correctly, and verify the update
command
that your commandbuilder is building. It' hard to tell right now without
knowing a little more... if you can narrow down the row (unless it's
happening to all of them) this would be helpful too.

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Jeremy" <je****@ninprodata.com> wrote in message
news:uF*************@TK2MSFTNGP15.phx.gbl...
My app is throwing an exception regarding trying to post a null to a
required field. Examining the datarow in question, I see a valid date
value. The row's state is "added"

I'm relying on an oledbcommandbuilder to supply the missing insert or
update commands. The following shows how I'm creating my components:

Private mdaCertByID As New OleDbDataAdapter 'selects a single cert by ID.
...
mdaCertByID.SelectCommand = New OleDbCommand
With mdaCertByID.SelectCommand
.Connection = NewCnnData()
.CommandType = CommandType.Text
.CommandText = "select * from Cert where id=@certid"
.Parameters.Add("@certid", OleDbType.Integer)
End With
mcbCertByID = New OleDbCommandBuilder(mdaCertByID)

Here's where I execute the update:

Public Function updatePanTixRow() As Boolean
Dim r As DataRow
Dim n As IntegerAddHandler mdaCertByID.RowUpdated, New
OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
Try
If Not dsData.HasErrors Then
n = mdaCertByID.Update(dsData, "cert")
updatePanTixRow = True
Else
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox("Row " + r.Item("id") + _
" of " + dsData.Tables("cert").Rows.Count.ToString + " rows: "
+
r.RowError)
End If
Next
updatePanTixRow = False
End If
'Debug.WriteLine(mcbCertByID.GetUpdateCommand.Comm andText)
Catch ex As Exception
updatePanTixRow = False
Debug.WriteLine(mcbCertByID.GetInsertCommand.Comma ndText)
For Each r In dsData.Tables("cert").Rows
If r.HasErrors Then
MsgBox(r.RowError)
r.RowError = ""
Else
MsgBox(ex.Message)
End If
Next
End Try
End Function


Nov 21 '05 #4
Output from immediate:

?dsdata.Tables("cert").Rows(0).Item(6)
#5/10/2005# {Date}
[Date]: #5/10/2005#
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
13
by: abdoly | last post by:
i wrote a code to update datagrid with the datagrid updatecommand but i cant get the updated values after being update that is the code private void DataGrid1_UpdateCommand(object source,...
2
by: Agnes | last post by:
daSeaInvInfo.SelectCommand = New SqlCommand daSeaInvInfo.SelectCommand.Connection = conSea 'daSeaInvInfo.TableMappings.Add("Table", "InvoiceHeader") daSeaInvInfo.SelectCommand.CommandText =...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
1
by: cindy | last post by:
this is the call private void Page_Load(object sender, System.EventArgs e) { OdbcConnection connection = new OdbcConnection ("DSN=PFW52"); CreateDataAdapter(connection); } this is the code,...
9
by: marcmc | last post by:
When I configure the dataAdaptor i get "Could not determine which columns uniquely identify the rows for TableName" and so the update and delete statements are not built.
1
by: marcmc | last post by:
My dataset is not updating my database after the user modifies the datagrid. I populate my data with the load sub below. In the Save Sub (below), I have generated my DataSet 'dataSet11' from my...
3
by: tayalamit7 | last post by:
Hey guys plzz help me in this , i am trying to delete row in database using disconnected architecture . it shows item deleted in datatable but does not delete in database here is my code Dim...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.