2010年6月3日 星期四

xml parsercode 資料庫(單純取得數量)ExecuteScalar(執行)ExecuteNonQuery

Dim xmlFile As String = MyFn
Dim MYsettings As New XmlReaderSettings '宣告 設定
MYsettings.IgnoreWhitespace = True '忽略空白
MYsettings.IgnoreProcessingInstructions = True '忽略前置處理指令
Dim Reader As XmlReader = XmlReader.Create(xmlFile, MYsettings)


While Reader.Read
'針對節點(Element)來做處理
Select Case Reader.NodeType
Case XmlNodeType.Element
'Reader.NodeType = XmlNodeType.Element
'Response.Write(Reader.Depth & " " & Reader.Name)
'************************************************************************************************************************************************** ' ' 只要有屬性擷取的問題時,都必須在此做處理!,不能跑到更內層去! ' ' '************************************************************************************************************************************************** '取得 公司 '處理是否有[屬性值] 若有循序讀出
Dim Sn As String = Reader.Name
If Reader.HasAttributes Then
'MsgBox("進入屬性")
For i = 0 To Reader.AttributeCount - 1
Reader.MoveToAttribute(i)
'MsgBox(i & " " & Reader.ToString)
If Reader.Name = "電信業者" Then
If Sn = "目標電話" Then
Sv(8) = Reader.Value
Exit For
Else
Sv(9) = Reader.Value
Exit For
End If
End If
Next
Reader.MoveToElement() '返回到節點(Element)上
End If 'MsgBox(Sv(8)) 'Exit Sub


Select Case Reader.Depth '針對不同階層處理。
Case 1 '單號
RowDepth = True
GetReadn = Reader.Name
Select Case GetReadn
Case "文號", "業者"
MyC = Reader.ReadString
If Len(MyC) <> 0 Then
MyCCnt = MyCCnt & MyC & "_"
End If
Case "查詢日期"

********************************略過

'先取得單號
Dim SQL As String = "SELECT max(oid) as maxR FROM [OrderNo] " Dim cmd As OleDbCommand = New OleDbCommand(SQL, conn) '誇號裡的第一個是SQL的字串,第二個是資料庫的聯結=OleDbConnection
Dim v As Integer = CInt(cmd.ExecuteScalar)
Glo_Oid = v '記錄目前單號
'若找不到記錄,就自動重新產生!


SQL = "INSERT INTO [a1] ([a2], [a3] , [a4], [a5], [a6], [a7],[a8], [a9], [a10], [a11], [a12], [a13],[a14],[a15] ) " & _ " VALUES ('" & Sv(0) & "','" & Sv(1) & "','" & Sv(2) & "','" & Sv(3) & "','" & Sv(4) & "','" & Sv(5) & _ "','" & Sv(6) & "','" & Sv(7) & "','" & Sv(8) & "','" & Sv(9) & "','" & Sv(10) & "','" & Sv(11) & "','" & Sv(12) & "'," & MyC & ") "
'MsgBox(SQL)
cmd = New OleDbCommand(SQL, conn) '誇號裡的第一個是SQL的字串,第二個是資料庫的聯結=OleDbConnection
cmd.ExecuteNonQuery() '執行SQL

沒有留言:

張貼留言

追蹤者