I am trying to store xml data in my database table using a stored procedure but data is not saving, I am not getting how can I do this..
My XML is
<?xml version="1.0" encoding="utf-16"?>
<Users>
<User ID="11005477969327">6/3/2011</User>
<User ID="11034688201594">5/18/2011</User>
</Users>
My stored procedure is
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
And my c# code here
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)
{
}