public DataTable dguser_SelectedIndexChanged()
{
string SqlString = "select * from mis where dm=@dim"; SqlConnection uSqlConnection = new SqlConnection("Data Source=localhost;Initial Catalog=web;User ID=sa;Password=sa"); SqlCommand cmd = new SqlCommand(SqlString, uSqlConnection);
cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@dim", SqlDbType.VarChar, 50);
cmd.Parameters["@dim"].Value = dmList.SelectedItem.Value;
SqlDataAdapter sd = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sd.Fill(ds);
return ds.Tables[0];
//cmd.Connection.Close(); }
{
string SqlString = "select * from mis where dm=@dim"; SqlConnection uSqlConnection = new SqlConnection("Data Source=localhost;Initial Catalog=web;User ID=sa;Password=sa"); SqlCommand cmd = new SqlCommand(SqlString, uSqlConnection);
cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@dim", SqlDbType.VarChar, 50);
cmd.Parameters["@dim"].Value = dmList.SelectedItem.Value;
SqlDataAdapter sd = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sd.Fill(ds);
return ds.Tables[0];
//cmd.Connection.Close(); }
public DataTable dguser_SelectedIndexChanged()
{
string SqlString = " SELECT * FROM mis where dm =@dm"; SqlConnection uSqlConnection = new SqlConnection("Data Source=localhost;Initial Catalog=web;User ID=sa;Password=sa"); SqlCommand cmd = new SqlCommand(SqlString, uSqlConnection);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("@dm", SqlDbType.VarChar, 50);
cmd.Parameters["@dm"].Value = DMList;
SqlDataAdapter sd = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sd.Fill(ds);
return ds.Tables[0];
}[/code]在sd.Fill(ds);处会提示:
"被准备语句'(@dm varchar(50))select*from mis where dm= @dm'需要参数@dm,但未提供该参数。"上一个问题也是这样子。麻烦再帮一下忙!谢了!