public DataTable GetAllByID(int EmployeeID)
{
DataTable dt = new DataTable();
SqlConnection mathConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnections"].ToString());
SqlCommand scmd = new SqlCommand(); this.scmd = new SqlCommand("GetAllByID", mathConnection);
this.scmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter sAda = new SqlDataAdapter("GetAllByID", mathConnection);
sAda.SelectCommand = scmd;
sAda.SelectCommand.CommandType = CommandType.StoredProcedure;
this.scmd.Parameters.Add("@myid", SqlDbType.Int);
this.scmd.Parameters["@myid"].Value = EmployeeID; try
{
this.mathConnection.Open();
this.scmd.ExecuteNonQuery();
this.sAda.Fill(ds);
this.mathConnection.Close();
}
catch
{
throw null;
}
return dt;
}
帮我看看有什么问题?谢谢!
编译不出错,运行绑不出数据!存储过程没有问题!求教
{
DataTable dt = new DataTable();
SqlConnection mathConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnections"].ToString());
SqlCommand scmd = new SqlCommand(); this.scmd = new SqlCommand("GetAllByID", mathConnection);
this.scmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter sAda = new SqlDataAdapter("GetAllByID", mathConnection);
sAda.SelectCommand = scmd;
sAda.SelectCommand.CommandType = CommandType.StoredProcedure;
this.scmd.Parameters.Add("@myid", SqlDbType.Int);
this.scmd.Parameters["@myid"].Value = EmployeeID; try
{
this.mathConnection.Open();
this.scmd.ExecuteNonQuery();
this.sAda.Fill(ds);
this.mathConnection.Close();
}
catch
{
throw null;
}
return dt;
}
帮我看看有什么问题?谢谢!
编译不出错,运行绑不出数据!存储过程没有问题!求教
new SqlConnection(connectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter();
SqlCommand scmd = new SqlCommand("GetAllByID", mathConnection);
scmd.CommandType = CommandType.StoredProcedure;
scmd.Parameters.Add("@myid", SqlDbType.Int);
scmd.Parameters["@myid"].Value = EmployeeID;
adapter.SelectCommand = scmd;
adapter.Fill(dataset);
return dataset.Tables[0];
}