日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Snake.Net

發(fā)布時間:2025/6/15 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Snake.Net 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

XML Web Service 數(shù)據(jù)交換

?

客戶端調(diào)用服務(wù)器端的 Web 服務(wù)并傳遞包含數(shù)據(jù)的 DataSet (ds)

?

Private Sub Synchronize()

??? Dim username As String = "JohnS"

??? Dim blnSuccess As Boolean

??? ' 使用 XML Web Service 進行同步

??? Cursor.Current = Cursors.WaitCursor

??? Dim wsFeedback As New wsFeedback.feedback

??? blnSuccess = wsFeedback.InsertFeedback(ds, username)

?

??? Cursor.Current = Cursors.Default

End Sub

?

服務(wù)器端的 Web 服務(wù)接受 DataSet 并將 XML 直接傳遞到 SQL Server 2000 存儲的過程中,該過程使用 SQLXML(英文)和 OPENXML 解析 XML 并將新數(shù)據(jù)插入適當(dāng)?shù)谋砀瘛?/span>

?

<WebMethod()> _

Public Function InsertFeedback(ByVal ds As DataSet, ByVal username As

? String) As Boolean

??? Dim con As New SqlConnection(connectionstring)

??? Dim cmd As New SqlCommand("p_Feedback_i", con)

??? cmd.CommandType = CommandType.StoredProcedure

?

??? ' 設(shè)置參數(shù)

??? Dim prmXML As SqlParameter = cmd.Parameters.Add("@XML",

????? SqlDbType.NText)

??? prmXML.Direction = ParameterDirection.Input

??? prmXML.Value = ds.GetXml

?

??? Dim prmUsername As SqlParameter = cmd.Parameters.Add("@Username",

????? SqlDbType.NVarChar)

??? prmUsername.Direction = ParameterDirection.Input

??? prmUsername.Value = username

?

??? Try

??? con.Open()

??????? cmd.ExecuteNonQuery()

??? Catch ex As Exception

??????? ' 處理、記錄并重擲錯誤

??????? Throw ex

?

??? Finally

??????? con.Close()

??? End Try

?

??? Return True

?

End Function

?

The stored procedure inserts the new data:

?

CREATE PROCEDURE p_Feedback_i

?? @XML ntext,

?? @Username nvarchar(50)

?

AS

?

SET NOCOUNT ON

?

DECLARE @iDoc? ?integer

DECLARE @Error?? integer

?

/* Create XML document. */

EXEC sp_xml_preparedocument @iDoc OUTPUT, @XML

?

/* Insert new records */

INSERT INTO??? Feedback

????? (

????? FeedbackID,

????? PlantSection,

????? Part,

????? DefectScope,

????? ScopeID,

???? ?DefectType,

????? RichInk,

????? Username

????? )

SELECT???? ID,

????? PlantSection,

????? Part,

????? DefectScope,

????? ScopeID,

????? DefectType,

????? RichInk,

????? @Username

FROM OPENXML (@iDoc, '/DataSet/Feedback',2) WITH

????? (

????? ID?? uniqueidentifier,

????? PlantSection?? int,

????? Part????? int,

????? DefectScope?? int,

????? ScopeID?? nvarchar(50),

????? DefectType?? int,

????? RichInk????? nvarchar(50)

????? )

?

SELECT @Error = @@ERROR

IF (@Error <> 0)

BEGIN

?? GOTO Errorhandler

END

?

/* Remove the XML document*/

EXEC sp_xml_removedocument @iDoc

?

RETURN

?

Errorhandler:

?

IF NOT @iDoc IS NULL

?? EXEC sp_xml_removedocument @iDoc

?

RAISERROR (@Error,16,1)

?

RETURN

?

《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的Snake.Net的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。