我在 Asp.net 中有一个项目,有人将数据插入 SQL Server 数据库,当他想调用最新插入的数据时(对于这个项目,我已经编写了一个存储过程,所以我将在 gridview 中使用它)他必须按一个按钮,一个网格视图来显示它们。
在gridview中我想添加我自己的模板(因为我有一些项目以及必须自己添加的Jquery Calendar)并将其绑定到服务器并选择存储过程来读取它。所以我必须从数据库读取数据的代码在这里:
protected void Button2_Click(object sender, EventArgs e)
{
SqlDataReader dr = DataProvider.ExecuteDataReader("[dbo].[Get_LastIdHowzeEducationFinishDate_SP]", CommandType.StoredProcedure);
GridView1.DataSource = dr;
SqlDataReader dr2 = DataProvider.ExecuteDataReader("[dbo].[Get_LastIdHowzeEducationField_SP]", CommandType.StoredProcedure);
GridView1.DataSource = dr2;
GridView1.DataBind();
}
但我不知道为什么只显示其中一个(第二个)同时我想在gridview中显示其他一些数据列。
这是我写的第一个存储过程:
ALTER PROCEDURE [dbo].[Get_LastInsertedRowHowzeEducation_SP]
AS
BEGIN
SELECT
he.FieldName as 'رشته تحصیلی',
he.SchoolName as 'نام موسسه آموزشی',
he.StudyCityDescribtion as 'محل تحصیل',
he.Average as 'معدل',
he.ThesisTitle as 'عنوان پایان نامه',
he.Describtion as 'توضیحات'
FROM
PersonHowEducation prh
INNER JOIN
HowzeEducation he ON prh.HowzeEducationId = he.HowzeEducationId
WHERE
prh.IdCode = (SELECT IdCode FROM Persons
WHERE IdCode = IDENT_CURRENT('persons'))
END
但是通过这段代码,我无法将 Jquery 日历添加到 gridview 中,所以我决定将它们分开,并为每一列编写一个过程,并通过 select 语句和 gridview 模板字段在 gridview 中调用它们。这是两个分开存储的程序:
ALTER PROCEDURE [dbo].[Get_LastIdHowzeEducationFinishDate_SP]
AS
BEGIN
select he.FinishLevelDate as 'تاریخ اتمام سطح'
from PersonHowEducation prh inner join HowzeEducation he on
prh.HowzeEducationId=he.HowzeEducationId
where prh.IdCode=
(Select IdCode from Persons where IdCode=IDENT_CURRENT('persons'))
END
和另一个:
ALTER PROCEDURE [dbo].[Get_LastInsertedRowHowzeEducation_SP]
AS
BEGIN
select he.FieldName as 'رشته تحصیلی',he.SchoolName as 'نام موسسه آموزشی',
he.StudyCityDescribtion as 'محل تحصیل',he.Average as 'معدل',
he.ThesisTitle as 'عنوان پایان نامه',
he.Describtion as 'توضیحات'
from PersonHowEducation prh inner join HowzeEducation he on
prh.HowzeEducationId=he.HowzeEducationId
where prh.IdCode=
(Select IdCode from Persons where IdCode=IDENT_CURRENT('persons'))
END