Sau đây là quy trình được lưu trữ của tôi.Cách nhận dữ liệu theo kết quả của thủ tục đã lưu
ALTER PROCEDURE SP_GetModels
(
@CategoryID bigint
)
AS
BEGIN
Select ModelID,ModelName From Model where [email protected]
END
và tôi đang gọi thủ tục lưu trữ trong mã đằng sau như
public SqlConnection conn;
public SqlDataReader GetModels()
{
DataTable dt = new DataTable();
public void DbConnection()
{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SampleCs"].ConnectionString);
conn.Open();
}
DbConnection();
SqlCommand cmd = new SqlCommand("SP_GetModels", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@CategoryID", SqlDbType.BigInt, 10).Value = CategoryID;
// SqlDataAdapter madap = new SqlDataAdapter(cmd, conn);
SqlDataReader dreader= cmd.ExecuteReader();
//madap.Fill(dt);
return dreader;
}
Tôi có một DropDownList mà tôi có để ràng buộc đối tượng DataReader có chứa modelname. làm thế nào tôi có thể thiết lập nguồn dữ liệu để DropDownList như datareader
gì về việc có sản lượng param từ t sql bên cạnh DataTable? làm thế nào để có được param đầu ra quá? Có thể không? Mẫu vật? –