Hi,
Shouldn't you add some data to the new row before you add it to
the datatable.
Ken
-------------------
Ken Tucker said:
Hi,
Post some code
Ken
----------------------
Ken, here it is ..
Public Function newPanTixRow() As DataRow
mdsData.Tables("Cert").Clear()
newPanTixRow = mdsData.Tables("Cert").NewRow
mdsData.Tables("Cert").Rows.Add(newPanTixRow)
End Function
Public Sub New
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
With mdaCertByID
.MissingSchemaAction = MissingSchemaAction.AddWithKey
Try
.FillSchema(mdsData, SchemaType.Source, "Cert")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End With
mcbCertByID = New OleDbCommandBuilder(mdaCertByID)
End Sub
Public Function updatePanTixRow() As Boolean
Dim r As DataRow
Dim n As Integer 'jhg 02/25/2005
AddHandler mdaCertByID.RowUpdated, New
OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
Try
If Not dsData.HasErrors Then
mcbCertByID.RefreshSchema()
mdaCertByID.Update(mdsData.Tables("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
Catch ex As Exception
updatePanTixRow = False 'jhg 02/24/2005
Debug.WriteLine(mcbCertByID.GetInsertCommand.CommandText)
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
Private Sub OnRowUpdated(ByVal sender As Object, ByVal args As
OleDbRowUpdatedEventArgs)
Dim newID As Integer = 0
Dim idCMD As OleDbCommand = New OleDbCommand("SELECT @@IDENTITY",
mdaCertByID.SelectCommand.Connection) 'mNQI.cnnData)
If args.StatementType = StatementType.Insert Then
newID = CInt(idCMD.ExecuteScalar())
args.Row("ID") = newID
End If
End Sub