I am using VB6 with MySql. I want a user to enter a reference and then when a command button is clicked, the columns associated with that reference are returned. What checks do I need to do if the record doesn't exist? Thank you.
Dim rs1 As ADODB.Recordset
Dim DB1 As New ADODB.Connection
Dim sSQL1 As String
sSQL1 = "select * from item_tracker where reference like ('" & txtReference.Text & "');"
DB1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False; UID=root@localhost ; database=mysql; option=3"
DB1.Open "data source=myodbc"
DB1.Execute ("USE Mysql;")
Set rs1 = New ADODB.Recordset
rs1.Open sSQL1, DB1, adOpenForwardOnly, adLockReadOnly, adCmdText
txtItem1.Text = rs1.Fields("item1")
txtItem2.Text = rs1.Fields("item2")
txtItem3.Text = rs1.Fields("item3")
txtItem4.Text = rs1.Fields("item4")
I am checking to see if what is entered in 'reference' is in the database. If it is I want the record returned. If not I want an error message and then let the user try again. Right noe I get a runtime 3021 error 'Either EOF or BOF is true or the current record has been deleted...'