SQL server 2000 +ADO.net

  • 10 years ago
    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:

    Dim mSQMXML ="<ROOT><Item1 Ma='0' ten ='gdsfgsdf' SDT='45456'></Item1></ROOT>"

    Dim mTableName ="User"

    Dim

    mycom As New SqlCommand("sp_Add_Table", Ket_noi)

    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

    If Ket_noi.State = ConnectionState.Closed Then Ket_noi.Open()

    Try

    mycom.ExecuteScalar()

    Doc_bang(0)

    Return True

    Catch ex As Exception

    Return False

    End Try

    But When I run then I see a Error : "Line1: Incorrect syntax near ' 0' "

    help me! Thanks

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.” - Dennis Ritchie