hi, the below coding of inserting data into database MS Access. So , may i ask what is the meaning for the coding i bold. Why the maxrow>0 , the message will come out? thanks.
con.Open()
sql = "SELECT * FROM summary WHERE line = '" & cbLine.Text & "' AND plants = '" & cbPlant.Text & "' AND dates = #" & dtp.Value & " #"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "summary")
[B]maxrow = ds.Tables("summary").Rows.Count[/B]
If [B]maxrow > 0 [/B]Then
MsgBox(cbLine.Text & " #" & dtp.Value & " #" & cbPlant.Text & "# already exist")
Else
Try
Dim addUser As String = "INSERT INTO summary (line, plants, dates,PartID, PartMD) VALUES ( '" & cbLine.Text.ToUpper & "','" & cbPlant.Text.ToUpper & "', #" & dtp.Value & "#, '" & p1.Text & "', '" & p2.Text & "')"
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(addUser, con)
cmd.ExecuteNonQuery()
MsgBox("Data have been save.")
Catch ex As Exception
MsgBox(ex.Message.ToString, , "Addition Error")
End Try
End If
con.Close()
End If