wallaceoc80
Programmer
Here is a snippet of code that I use to query my database in ASP.NET
I then go on to bind the resulting data to a DataGrid.
What I also want to do is query the Database for a single value. I want to query one of the above Tables (Application) to retrieve the value of one column for a row meeting the condition I provide. I then want to set the value of a Label to the value returned from the Database.
How do I go about this? Do I still use a Dataset when I'm only getting one value and I'm not binding it to a DataGrid?
Any ideas would be appreciated.
Regards,
Wallace
Code:
string query = "Select F.AppID, F.FAQID, F.FAQ, F.Criticality";
query += " from FAQ F, Application A";
query += " where F.AppID = A.AppID";
query += " AND F.AppID = " + selectedAppID;
query += " AND F.FAQ LIKE '%" + keyword + "%'";
try
{
SqlDataAdapter dataAdapter = new SqlDataAdapter(query, strConnection);
searchData = new DataSet();
dataAdapter.Fill(searchData);
string query2 = "Select GripsID";
query2 += " from Application";
query2 += " where appID = " + keyword;
conn.Dispose();
}
I then go on to bind the resulting data to a DataGrid.
What I also want to do is query the Database for a single value. I want to query one of the above Tables (Application) to retrieve the value of one column for a row meeting the condition I provide. I then want to set the value of a Label to the value returned from the Database.
How do I go about this? Do I still use a Dataset when I'm only getting one value and I'm not binding it to a DataGrid?
Any ideas would be appreciated.
Regards,
Wallace