我試圖使用存儲過程在數據庫表中存儲xml數據,但數據未保存,我不知道如何才能做到這一點..如何使用SQL Server存儲過程在表中保存XML數據
我的XML是
<?xml version="1.0" encoding="utf-16"?>
<Users>
<User ID="11005477969327">6/3/2011</User>
<User ID="11034688201594">5/18/2011</User>
</Users>
我的存儲過程是
Alter PROCEDURE [ProcessMailNotificationSentToUsers]
@User_XML XML
AS
BEGIN
DECLARE @hdoc int
DECLARE @doc varchar(2000)
SET @doc = ''
EXEC sp_xml_preparedocument @hdoc OUTPUT, @doc
--OPEN XML example of inserting multiple customers into a Table.
INSERT INTO PasswordExpiryNotificationLog (UserId)
SELECT UserId FROM OPENXML (@hdoc, '/Users/User',2)
WITH(
UserId bigint
)
EXEC sp_xml_removedocument @hdoc
END
而且我的C#代碼這裏
SqlParameter[] arrParam = new SqlParameter[1];
try
{
SqlConnection objConn = new SqlConnection(GetConnection());
string strProc = "ProcessMailNotificationSentToUsers";
arrParam[0] = new SqlParameter("@User_XML", SqlDbType.Xml);
arrParam[0].Value = userXML;
SqlHelper.ExecuteNonQuery(objConn, CommandType.StoredProcedure, strProc, arrParam);
}
catch (Exception ex)
{
}
它的商店* d *程序 - 如** **存儲在SQL Server中 - 它有沒有與「商店* ... –