Currently I do the multiple rows update by using the dataset and looping
the update SQL query the number of times the rows exist in the dataset. Below is an example. This seems odd to me, Is there a better way I can update multiple rows in the table? Thanks in advance.
Private Function updateEmployee(ByVal ds As DataSet)
Dim irow As DataRow
Dim strSQL As String
Dim myCommand As OleDbCommand
Dim conn As OleDbConnection
Dim intRowsAffected As Integer
dim name, phone, email as string
conn = New OleDbConnection(ConnectionString)
conn.Open()
Try
For Each irow In ds.Tables(0).Rows
name = irow.Item("Name"
phone = irow.Item("Phone"
email = irow.Item("email"
strSQL = "UPDATE Employee_Detail SET" & " "
strSQL += "EmployeeName= " & PrepareStr(name) & ", "
strSQL += "Phone = " & PrepareStr(phone) & ", "
strSQL += "Email = " & PrepareStr(email) & " "
strSQL += "WHERE (((EmployeeID)=" & PrepareStr(employeeID) & "
) "
myCommand = New OleDbCommand(strSQL, conn)
intRowsAffected = myCommand.ExecuteNonQuery()
Next
Finally
conn.Close()
conn.Dispose()
myCommand.Dispose()
End Try
End function
the update SQL query the number of times the rows exist in the dataset. Below is an example. This seems odd to me, Is there a better way I can update multiple rows in the table? Thanks in advance.
Private Function updateEmployee(ByVal ds As DataSet)
Dim irow As DataRow
Dim strSQL As String
Dim myCommand As OleDbCommand
Dim conn As OleDbConnection
Dim intRowsAffected As Integer
dim name, phone, email as string
conn = New OleDbConnection(ConnectionString)
conn.Open()
Try
For Each irow In ds.Tables(0).Rows
name = irow.Item("Name"

phone = irow.Item("Phone"

email = irow.Item("email"

strSQL = "UPDATE Employee_Detail SET" & " "
strSQL += "EmployeeName= " & PrepareStr(name) & ", "
strSQL += "Phone = " & PrepareStr(phone) & ", "
strSQL += "Email = " & PrepareStr(email) & " "
strSQL += "WHERE (((EmployeeID)=" & PrepareStr(employeeID) & "

myCommand = New OleDbCommand(strSQL, conn)
intRowsAffected = myCommand.ExecuteNonQuery()
Next
Finally
conn.Close()
conn.Dispose()
myCommand.Dispose()
End Try
End function