Hi all!
I have a problem :
I Build a procedure :
CREATE PROCEDURE sp_Add_Table
@InvData ntext, @TableName varchar(30)
AS
DECLARE
@queryStr varchar(1000)
--BEGIN TRAN CAPNHAT
--SAVE TRAN FIRST
set @queryStr='Declare @hdoc int
Exec sp_xml_preparedocument @hDoc OUTPUT,''' + convert(nvarchar(1000),@InvData) +
''' Insert into ' +@TableName +' Select * from OPENXML(@hdoc,''ROOT/Item1'') with ' + @TableName +
' EXEC sp_xml_removedocument @hDoc'
Exec (@queryStr)
IF @@ERROR<>0
BEGIN
ROLLBACK TRAN FIRST
RETURN -100
END
COMMIT TRANSACTION
GO
Then I Using this procedure by code:
string mSQMXML ="<ROOT><Item1 Ma='0' ten ='gdsfgsdf' SDT='45456'></Item1></ROOT>";
string mTableName ="User";
SqlCommand
mycom = new SqlCommand("sp_Add_Table", Cnn);
mycom.CommandType =
CommandType.StoredProcedure;
mycom.Parameters.Add(
"@InvData", SqlDbType.NText);
mycom.Parameters.Add(
"@TableName", SqlDbType.VarChar, 30);
mycom.Parameters(
"@TableName").Value = mTableName;
mycom.Parameters(
"@InvData").Value = mSqlXML;
try
{
mycom.ExecuteScalar();
}
catch
{
}
But When I run then I see a Error : "Line1: Incorrect syntax near ' 0' "
help me! Thanks