J
J_Mohan
Guest
Hi,
I am trying to copy selected records from one access table to another, but each time only first record get inserted in to the destination table. I have tried as follows:
Sub DataTrans()
Dbconnection.Open()
Dim StrArr(2) As String
MasterReader = MasterCmd.ExecuteReader()
Try
While MasterReader.Read()
StrArr(0) = (MasterReader("CPF_No".ToString))
StrArr(1) = (MasterReader("Name".ToString))
StrArr(2) = (MasterReader("Designation".ToString))
Try
LvMasterCmd.CommandText = "INSERT INTO LeaveMaster" &
"(CPF_No, Name, Designation, MNT, YR, LeaveStatus)" &
"VALUES ( @CPF_No, @name, @Designation, @MNT, @YR, @LeaveStatus) ;"
LvMasterCmd.Parameters.AddWithValue("@CPF_No", StrArr(0))
LvMasterCmd.Parameters.AddWithValue("@name", StrArr(1))
LvMasterCmd.Parameters.AddWithValue("@Designation", StrArr(2))
LvMasterCmd.Parameters.AddWithValue("@MNT", CmbMonth.Text)
LvMasterCmd.Parameters.AddWithValue("@YR", CmbYear.Text)
LvMasterCmd.Parameters.AddWithValue("@LeaveStatus", "N")
LvMasterCmd.ExecuteNonQuery()
Catch ex As Exception
End Try
End While
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dbconnection.Close()
End Sub
Continue reading...
I am trying to copy selected records from one access table to another, but each time only first record get inserted in to the destination table. I have tried as follows:
Sub DataTrans()
Dbconnection.Open()
Dim StrArr(2) As String
MasterReader = MasterCmd.ExecuteReader()
Try
While MasterReader.Read()
StrArr(0) = (MasterReader("CPF_No".ToString))
StrArr(1) = (MasterReader("Name".ToString))
StrArr(2) = (MasterReader("Designation".ToString))
Try
LvMasterCmd.CommandText = "INSERT INTO LeaveMaster" &
"(CPF_No, Name, Designation, MNT, YR, LeaveStatus)" &
"VALUES ( @CPF_No, @name, @Designation, @MNT, @YR, @LeaveStatus) ;"
LvMasterCmd.Parameters.AddWithValue("@CPF_No", StrArr(0))
LvMasterCmd.Parameters.AddWithValue("@name", StrArr(1))
LvMasterCmd.Parameters.AddWithValue("@Designation", StrArr(2))
LvMasterCmd.Parameters.AddWithValue("@MNT", CmbMonth.Text)
LvMasterCmd.Parameters.AddWithValue("@YR", CmbYear.Text)
LvMasterCmd.Parameters.AddWithValue("@LeaveStatus", "N")
LvMasterCmd.ExecuteNonQuery()
Catch ex As Exception
End Try
End While
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dbconnection.Close()
End Sub
Continue reading...