I am making a small project to build my skills, and what I am trying to do is query a DataSet which is filled from a SQL database using a SELECT query.
However, I cannot manage to query the dataset further, I would like to be able to search the dataset and it will pull up results, this is what I have so far, though I get this error - An unhandled exception of type 'System.NullReferenceException' occurred
My table is called Animals, and I am searching in the parlour_number column.
I have searched, but I don't understand most of what I have looked at, I have a very basic understanding still.
DataSet ds;
DataRow dRow;
private void searchBtn_Click(object sender, EventArgs e)
{
string searchFor = tbSearch.Text;
int results = 0;
DataRow[] returnedRows;
returnedRows = ds.Tables["Animals"].Select("parlour_number='" + searchFor + "'");
results = returnedRows.Length;
if(results > 0)
{
dRow = returnedRows[0];
MessageBox.Show(dRow[1].ToString() + " " + dRow[2].ToString());
}
else
{
MessageBox.Show("No records found");
}
}