Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi all,

 

I already know how to do the search function..

But I need to do a perfect one.

here is my code which is working

SqlCeCommand cmd = conn.CreateCommand();
			cmd.CommandText = querySQL;
			SqlCeDataReader rdr = cmd.ExecuteReader();
			while (rdr.Read())
			{
				TXT_Description.Text = rdr.GetString(1);
				TXT_Something.Text = rdr.GetString(2);
			}
			cmd = null;
			rdr.Close();

so it will return TXT....Text whatever I want to know.. But how should I do if the data not found in the database?

I want to place a message "Data Not Found"

How to code?

Posted

I think if you initialize your string value(s) to your "Data Not Found" message prior to the loop you should be set.

 

It's been a while since I used a datareader, but I think if you have any empty result-set the loop won't even run once, since it's top-checked.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...