Code Part Change
StringBuilder sbXml = new StringBuilder();
sbXml.Append("<MyDetails>");
foreach (DataGridItem item in this.dgUserLeave.Items)
{
sbXml.Append("<Details EmpId=\"" + ViewState["empid"].ToString() + "\" FromDt=\"" + item.Cells[1].Text.ToString() + "\"/>");
}
sbXml.Append("</MyDetails>");
return sbXml.ToString();
Access the same in SQL
/*
Proc_AddLeave '<MyDetails><Details EmpId="953" FromDt="05/02/2012"/><Details EmpId="953" FromDt="05/02/2012"/></LeaveDetails>'
*/
CREATE PROC Proc_MyProc ( @Detailss xml )
AS
BEGIN
--INSERT INTO #tmpTable
SELECT
x.value('@EmpId', 'int') EmpId,
x.value('@FromDt', 'date') FromDt
FROM @Detailss.nodes('LeaveDetails/Details') AS a(x)
END
StringBuilder sbXml = new StringBuilder();
sbXml.Append("<MyDetails>");
foreach (DataGridItem item in this.dgUserLeave.Items)
{
sbXml.Append("<Details EmpId=\"" + ViewState["empid"].ToString() + "\" FromDt=\"" + item.Cells[1].Text.ToString() + "\"/>");
}
sbXml.Append("</MyDetails>");
return sbXml.ToString();
Access the same in SQL
/*
Proc_AddLeave '<MyDetails><Details EmpId="953" FromDt="05/02/2012"/><Details EmpId="953" FromDt="05/02/2012"/></LeaveDetails>'
*/
CREATE PROC Proc_MyProc ( @Detailss xml )
AS
BEGIN
--INSERT INTO #tmpTable
SELECT
x.value('@EmpId', 'int') EmpId,
x.value('@FromDt', 'date') FromDt
FROM @Detailss.nodes('LeaveDetails/Details') AS a(x)
END
No comments:
Post a Comment