C# SqlDataAdapter not populating DataSet
Posted
by Wesley
on Stack Overflow
See other posts from Stack Overflow
or by Wesley
Published on 2010-04-20T17:16:12Z
Indexed on
2010/04/20
17:23 UTC
Read the original article
Hit count: 334
I have searched the net and searched the net only to not quite find the probably I am running into. I am currently having an issue getting a SqlDataAdapter to populate a DataSet. I am running Visual Studio 2008 and the query is being sent to a local instance of SqlServer 2008. If I run the query itself in SqlServer, I do get information. Code is as follows:
string theQuery = "select Password from Employees where employee_ID = '@EmplID'";
SqlDataAdapter theDataAdapter = new SqlDataAdapter();
theDataAdapter.SelectCommand = new SqlCommand(theQuery, conn);
theDataAdapter.SelectCommand.Parameters.Add("@EmplID", SqlDbType.VarChar).Value = "EmployeeName";
theDataAdapter.Fill(theSet);
The code to read the dataset:
foreach (DataRow theRow in theSet.Tables[0].Rows)
{
//process row info
}
If there is any more info I can supply please let me know.
© Stack Overflow or respective owner