G
Guest
Hi,
I'm returning rows from a search done using a sp & one input parameter.
Therefore I am using a command to return the result set. These need to go
into a dataset in order for it to be bound to a data grid. I received two
ways to do it from this discussion group but neither work for me. The First
was directly from the command object to the dataset, as below:
dsResults.Tables["resultTable"] = comSearchByName.ExecuteReader();
// didn't work
The second was via a DataAdapter, as below, except the example i was given
used a string instead of a command. I want to use a command:
SqlDataAdapter da = new SqlDataAdapter(comSearchByName,sqlConnection1);
but received an error:
Cannot convert from System.Data.SqlClient.SQLCommand to string
I would prefer not to use a data Adapter & do it straight from the command
if possible, but if this is not possible, how do I use the data Adapter
without raising the specified error?
Hope someone can help out
Thanks in advance
Ant
SqlDataAdapter da = new SqlDataAdapter(comSearchByName,sqlConnection1);
however, this creates the error below:
I'm returning rows from a search done using a sp & one input parameter.
Therefore I am using a command to return the result set. These need to go
into a dataset in order for it to be bound to a data grid. I received two
ways to do it from this discussion group but neither work for me. The First
was directly from the command object to the dataset, as below:
dsResults.Tables["resultTable"] = comSearchByName.ExecuteReader();
// didn't work
The second was via a DataAdapter, as below, except the example i was given
used a string instead of a command. I want to use a command:
SqlDataAdapter da = new SqlDataAdapter(comSearchByName,sqlConnection1);
but received an error:
Cannot convert from System.Data.SqlClient.SQLCommand to string
I would prefer not to use a data Adapter & do it straight from the command
if possible, but if this is not possible, how do I use the data Adapter
without raising the specified error?
Hope someone can help out
Thanks in advance
Ant
SqlDataAdapter da = new SqlDataAdapter(comSearchByName,sqlConnection1);
however, this creates the error below: