-2

The first search I perform is always successful but trying to search again after that I get the following error. Any help will be appreciated.

Vb.net Error

A Friend
  • 2,750
  • 2
  • 14
  • 23
  • The error itself is already telling you what the issue is. From the code in that image, your dataset doesn't have any table if the eval is true – EdSF Feb 22 '17 at 08:02
  • Nick, welcome to SO. Kindly take the [tour] to gain an understanding of how things work round here. Your question has been answered. You should consider marking it as accepted. I'd also strongly advise looking over the duplicate link as it will help you gain a better understanding of your error. – Bugs Feb 22 '17 at 10:39
  • Kindly read [ask] and take the [tour]. Questions need the related code in the question as text, not links and not pictures. The same for error messages. – Ňɏssa Pøngjǣrdenlarp Feb 22 '17 at 13:57

1 Answers1

0

As EdSF points out you have no tables after the first search. This is because you set IsFind to ensure you've already searched, but you create a new dataset anyway datast = New DataSet which will have no tables.

If this was unintended, then you can do:

If datast IsNot Nothing AndAlso datast.Tables IsNot Nothing AndAlso datast.Tables("tblproduct") IsNot Nothing Then

Or the short way (VS2015+) using null propagation.

datast?.Tables?("tblproduct")?.Clear()

If this is intended, and you want a new DataSet every time, then just remove that If block, it does nothing.

Community
  • 1
  • 1
A Friend
  • 2,750
  • 2
  • 14
  • 23