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

UpdateBatch error When Delete Rows

P: n/a
This is my error :
<<impossible to approach the information on the line eliminated through the line>>

This is my code for updateBatch :

Private mSqlConn as sqlConnection

Public Function UpdateBatch(ByVal DTable As DataTable)
Dim mSqlDa As SqlDataAdapter
Dim MustCloseConnection As Boolean
Dim mDtable As DataTable
Dim mSqlCmd As New SqlCommand("SELECT * FROM TBL" & DTable.TableName, mSqlConn)
mSqlCmd.CommandType = CommandType.Text
mSqlDa = New SqlDataAdapter(mSqlCmd)
mSqlDa.FillSchema(DTable, SchemaType.Source)
Dim cmdBuilder As New SqlCommandBuilder(mSqlDa)
mSqlDa.InsertCommand = cmdBuilder.GetInsertCommand
mSqlDa.DeleteCommand = cmdBuilder.GetDeleteCommand
mSqlDa.UpdateCommand = cmdBuilder.GetUpdateCommand
mSqlDa.Update(DTable)
mSqlDa.Dispose()
mSqlCmd.Dispose()
End Function

In my datatable i insert data and deletedata

Procedure Insert Data in a datatable :
'-----------------------------------------------------------
private sub InsertDtRow
DtRow = DTable .NewRow
DtRow("C1") = txt1.text -PRIMARY KEY
DtRow("C2") = txt2.text - PRIMARY KEY
DtRow("C3") = txt3.text
DtRow("C4") = txt4.text
DtRow("C5") =txt5.text
DTable .Rows.Add(DtRow)
DtRow = Nothing
end sub
'-------------------------------------------------------------

'Procedure delete data in a datatable
'----------------------------------------------------------------
private sub DeleteDtRow
Dim DtRow() As DataRow
DtRow = DTable .Select("C1=1 AND C2 = 2")

If DtRow.GetUpperBound(0) <> -1 Then
DtRow(0).Delete()
End If
end sub
'----------------------------------------------------------------

to the end I call UpdateBatch(DtTable) for update my table in db....
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.