dim x as integer = 0
str = "SELECT uname, full_name FROM EMPLOYEE"
cmd = New MySqlCommand(str, cn)
ds = New DataSet
da = New MySqlDataAdapter(str, cn)
da.Fill(ds, "employee")
Dim uname As String = ds.Tables(0).Rows(0)("uname").ToString
Dim emp_name As String = ds.Tables(0).Rows(0)("full_name").ToString
While x <= ds.Tables(0).Rows.Count
If ds.Tables(0).Rows.Count <> 0 Then
' MsgBox("!")
str = "SELECT * FROM attendance where date = '" & Label3.Text & "' and uname = '" & uname & "' and emp_name = '" & emp_name & "'"
cmd = New MySqlCommand(str, cn)
ds = New DataSet
da = New MySqlDataAdapter(str, cn)
da.Fill(ds, "attendance")
While x <= ds.Tables(0).Rows.Count
If ds.Tables(0).Rows.Count = False Then
cmd.CommandText = "INSERT INTO ATTENDANCE(date,emp_name,tin1,uname)VALUES('" & Label3.Text & "', '" & emp_name & "', 'ABSENT', '" & uname & "')"
cmd.ExecuteNonQuery()
End If
x = x + 1
End While
End If
x = x + 1
cn.Close()
End While
This is my code of inserting multiple records using while loop but it only inserts a single record. I want to insert multiple records at the same using this. How can I do this. Please check my code. Any help is much appreciated.thank you.