How to check if value exist in database
I have a value let's say it's "3243"; and my database table name is "mytable" and the column I'll look into is "mycolumn". I want to check if this value exist in that column.
I do have a dataset and I tried the following code :
DataTable table = dsEditData.Tables["mytable"];
DataRow[] row;
row = table.Select("mycolumn = '3243'");
MessageBox.Show(row[0][0].ToString());
but this code gives me the error "There is no row at position 0."
Database table is not empty and I'm %100 sure that the row I'm looking for exist. I've never used these codes. So it might be totally wrong. I want to know if I need to correct my code or if there is any other way to do what I want to do.