|
-
Sep 16th, 2002, 08:57 PM
#1
Thread Starter
Addicted Member
a simple database query
Just looking for a simple example of how to query a database and determine if a value is in it. I want to return true if it is there and false if it is not.... I mucked around with one example here is what I have so far.... any ideas??
/*Check to see if the company is in the database*/
private bool CheckCompany(string CompanyName){
string strConnection = "server=localhost; uid=sa; pwd=; database=Company";
string strCommand = "SELECT * from CompanyNames WHERE name = 'CompanyName' ";
SqlDataAdapter dataAdapter = new SqlDataAdapter(strCommand,strConnection);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet,"Companies");
SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter);
DataTable dataTable = dataSet.Tables[0];
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|