I know how to do it this way ... which works ...
conn = new
SqlConnection(System.Configuration.ConfigurationMa nager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
// 1. create a command object identifying
// the stored procedure
SqlCommand cmd = new SqlCommand(
"dbo.insertProjectFile", conn);
// 2. set the command object so it knows
// to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
// 3. add parameter to command, which
// will be passed to the stored procedure
cmd.Parameters.Add(new SqlParameter("@StrFileName", StrFileName));
cmd.ExecuteNonQuery();
But I can't figure out how to do it with the sqladapator as it doesn't
have the cmd.ExecuteNonQuery(); at the end, but just binds to the
dataset with fill!
DeveloperX wrote:
I think something like this:
d.SelectCommand.Parameters.Add(new
System.Data.SqlClient.SqlParameter("paramname","pa ram"));
There are 7 overrides for the constructor on SqlParameter, I've just
picked the simple one. You may also have to add a SqlCommand to the
SelectCommand first.
dawson wrote:
Hello, from the code below, how do I add/send a parameter to the stored
procedure?
SqlConnection conn = null;
conn = new
SqlConnection(System.Configuration.ConfigurationMa nager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
SqlDataAdapter daProjects = new SqlDataAdapter("dbo.getProjectFiles",
conn);
DataSet ds = new DataSet();
daProjects.Fill(ds);