Im working on an access database, and I want to know how can I fix the code below so that I could display the correct information to the user. The problem is, I want to display an error message if the oledbcommand did not succeed.
Try
cn = New OleDbConnection(" Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\ro.mdb")
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand("select * from [Table1]", cn)
cmd.CommandText = "insert into [Table1]([LNAME], [FNAME], [MNAME], [POS], [UNAME], [PASS]) values('" + lstname + "','" + frsname + "','" + midname + "','" + post + "','" + usrname + "','" + pword + "')"
cmd.ExecuteNonQuery()
Catch
MsgBox("Either one of the text box is empty or the IDNUMBER entered is already on the database", MsgBoxStyle.Critical)
End Try