Function selectDB17()
Dim cn As New SqlConnection
Dim cmd As New SqlCommand
cn.ConnectionString = ("server=EKS-HQ;database=BGB;user id=administrator;password=admineks2005")
cn.Open()
cmd.Connection = cn
cmd.CommandText = "SELECT KODSTATE,USERID,PASSWORD,KUMPULAN FROM USERID"
Dim lrd As SqlDataReader = cmd.ExecuteReader()
Try
Do While lrd.Read()
If lrd.HasRows Then
a = lrd("KODSTATE")
b = lrd("USERID")
c = lrd("PASSWORD")
d = lrd("KUMPULAN")
Else
MsgBox("Tiada Data")
End If
insertDB17()
Loop
Catch ex As Exception
MessageBox.Show("Error while retrieving records on table..." & ex.Message, "Load Records")
Finally
cn.Close()
End Try
End Function
Function insertDB17()
Dim con As OleDb.OleDbConnection
Dim str As String
Dim cmd As OleDb.OleDbCommand
Try
con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;data source=" & strsaveDB & "\" & strnameDB & ".mdb")
con.Open()
str = "insert into USERID(KODSTATE,USERID,PASSWORD,KUMPULAN)values('" & a & "' ,'" & b & "','" & c & "','" & d & "')"
cmd = New OleDb.OleDbCommand(str, con)
cmd.ExecuteNonQuery()
Catch
End Try
con.Close()
End Function
=================================================
hi..there..did anyone know what wrong with my code..i've fail to insert in table USERID in access..actually,i've use the same code to insert before this and it succeed..