how to check if theres no entry in the accessdatabase

  • Thread starter Thread starter Drygast
  • Start date Start date
D

Drygast

Hi,

I'm having some problems getting my program to work as I would like it to.
This is because i whish to check if the entered number exists in an
accessdatabase, if i doesn't I
would like to call a form where I can enter the number to the database....

the code:

______________
If Not myReader.GetInt32(1).ToString = txtOrdernummer.Text Then

If MessageBox.Show(("Ordern finns inte i databasen!" & vbCrLf & vbCrLf &
"vill du registrera ordern?"), "Hittar ej ordern", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation) = DialogResult.Yes Then

Dim oForm2 As Form2

oForm2 = New Form2

oForm2.Show()

oForm2 = Nothing

End If

End If

______________
I realize that this code is not correct, but I don't know what I should
type instead:

If Not myReader.GetInt32(1).ToString = txtOrdernummer.Text Then

It won't work with "if Not myReader.IsDbNull then" either, it must be cause
I don't even get a null answer but as I said:

how do I solve this?



Regards

/Drygast
 
Hi Drygast,
I think you are not debugging, but why not make it simple for yourself.
Put in this place a while
'''''''If Not myReader.GetInt32(1).ToString = txtOrdernummer.Text Then
Messagebox.show(myReader.GetInt32(1).ToString )
then you know what the value is.
I hope this helps
Cor
 
Hi Cor,

following your example this is the response:

"An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll

Additional information: No data exists for the row/column."

Any ideas?
I don't think this is a problem though, I just need to be able to catch the
event and when "No data exists for the row" happens
I call another form where I can enter the data (ordernumber). I just don't
know the code to do it (newbie-programmer)
/Drygast
 
Back
Top