Hi All,
I have a data table with hundreds of records and would like to insert them to the database in one batch.
Below is my coding. But it gives me error at the
da.Update(dt). What's wrong?
Private Sub InsertGLTable(ByVal GLRec As DataTable)
Dim conn As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("conGFIS"))
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim cb As SqlClient.SqlCommandBuilder
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "Insert_Test"
cmd.Parameters.Add("@JournalDate", SqlDbType.DateTime)
cmd.Parameters.Add("@DocumentNo", SqlDbType.Char)
conn.Open()
'da.updatebatchsize()
da.InsertCommand = cmd
da.Update(GLRec)
conn.Close()
End Sub
I have a data table with hundreds of records and would like to insert them to the database in one batch.
Below is my coding. But it gives me error at the
da.Update(dt). What's wrong?
Private Sub InsertGLTable(ByVal GLRec As DataTable)
Dim conn As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("conGFIS"))
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim cb As SqlClient.SqlCommandBuilder
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "Insert_Test"
cmd.Parameters.Add("@JournalDate", SqlDbType.DateTime)
cmd.Parameters.Add("@DocumentNo", SqlDbType.Char)
conn.Open()
'da.updatebatchsize()
da.InsertCommand = cmd
da.Update(GLRec)
conn.Close()
End Sub