Hi, this is the code I am trying. I cannot get it to work,
I think maybe I did not understand some of what you said.
Please help if you can
-
SqlDataAdapter testDataAdapter = new SqlDataAdapter();
-
SqlCommand testCommand =
-
testDataAdapter.SelectCommand;
-
testCommand.CommandType=
-
CommandType.StoredProcedure;
-
-
testCommand.CommandText="depreciation";
-
testCommand.Parameters.Add
-
("@CategoryID",SqlDbType.Int);
-
SqlParameter testInput =
-
testCommand.Parameters.Add("@CategoryID", SqlDbType.Int);
-
testInput.Direction =
-
ParameterDirection.Input;
-
testInput.Value= Convert.ToInt32
-
(index);
-
-
DataSet testDataSet = new DataSet();
-
testDataAdapter.Fill
-
(testDataSet, "Table1");
-
//dataGrid1.DataBindings =
-
testDataSet.Tables["Table1"];
-
dataGrid1.DataSource = testDataSet;
-
dataGrid1.DataMember = "invName";
-----Original Message-----
Wayde,
When you use the data adapter to fill a dataset, you
can set theSelectCommand to a SqlCommand where the CommandType
property isCommandType.StoredProcedure.
The CommandText property would be set to the name of
the storedprocedure.
Then, call the CreateParameter method on the
SqlCommand.
On that instance that is returned from the call to
CreateParameter, setthe SqlDbType property to SqlDbtype.Int. Set the
parameter value as well.
Then, call the Add method on the
SqlParameterCollection returned by theParameter property and add the parameter.
Finally, you can call Fill to get your data set.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
"Wayde" <to*****@hotmail.com> wrote in message
news:09****************************@phx.gbl...
Please help me if you know the answer to this. I want to
create a dataAdapter, that fills a dataSet. However, I
have a stored procedure that I want to use, that takes
one int as input. I have been trying this for a few hours
now, and have come no closer.
.