Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ถามเรื่องการ write ข้อมูลลง xml โดยใช้ภาษา VB.net



 

ถามเรื่องการ write ข้อมูลลง xml โดยใช้ภาษา VB.net

 



Topic : 117613



โพสกระทู้ ( 90 )
บทความ ( 0 )



สถานะออฟไลน์




ถ้าผมต้องการที่จะ update ข้อมูล xml ลงไปใน file
โดยที่ให้มันไม่ไป write ทับลงไปทั้ง file จะให้มันเข้าไปแก้ แค่ที่ละ field อะครับ

ต้องเขียนยังไงหรอครับ อย่างจะเอาเข้า DBserver 2 อะครับ

แต่ code ข้างล่างคือจะเอาเข้าแค่ DBserver 1 อย่างเดียว

คือผมจะทำหน้ากรอกข้อมูลไว้หลายหน้า แต่จะ เก็บ file xml ไว้แค่ file เดียว

แต่ตอนนี้คือมันไม่ อยู่ใน file เดียวกันอะครับ ไม่ทราบว่าต้องเขียนยังไงหรอครับ

xx

Code (ASP)
Imports System.Xml
Imports System.IO
Imports System.Data
Public Class Config_DB1ServerIP
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub
    Protected Sub cmdsave_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdsave.Click
        Dim DBServerIP As String
        Dim DBUsername As String
        Dim DBPassword As String
        Dim DBDatabaseName As String
        Dim DBTableName1 As String
        Dim DBTableName2 As String
        Dim DBTableName3 As String
        Dim DBTableName4 As String
        DBServerIP = DB1ServerIP1.Text
        DBUsername = DB1Username1.Text
        DBPassword = DB1Password1.Text
        DBDatabaseName = DB1DatabaseName1.Text
        DBTableName1 = DB1TableName11.Text
        DBTableName2 = DB1TableName21.Text
        DBTableName3 = DB1TableName31.Text
        DBTableName4 = DB1TableName41.Text
        If IO.File.Exists("Config.xml") = False Then
            'declare our xmlwritersettings object
            Dim settings As New XmlWriterSettings()
            'lets tell to our xmlwritersettings that it must use indention for our xml
            settings.Indent = True
            'lets create the MyXML.xml document, the first parameter was the Path/filename of xml file
            ' the second parameter was our xml settings
            Dim XmlWrt As XmlWriter = XmlWriter.Create("C:\Config.xml", settings)
            With XmlWrt
                ' Write the Xml declaration.
                .WriteStartDocument()
                ' Write the root element.
                .WriteStartElement("configuration")
                .WriteStartElement("DBServerIP")
                ' Start our first person.
                '.WriteStartElement("Person")
                ' The person nodes.
                'DB1ServerIP
                'DB1Username
                'DB1Password
                'DB1DatabaseName
                'DB1TableName1
                'DB1TableName2
                'DB1TableName3
                'DB1TableName4
                .WriteStartElement("DB1ServerIP")
                .WriteString(DBServerIP)
                .WriteEndElement()
                .WriteStartElement("DB1Username")
                .WriteString(DBUsername)
                .WriteEndElement()
                .WriteStartElement("DB1Password")
                .WriteString(DBPassword)
                .WriteEndElement()
                .WriteStartElement("DB1DatabaseName")
                .WriteString(DBDatabaseName)
                .WriteEndElement()
                .WriteStartElement("DB1TableName1")
                .WriteString(DBTableName1)
                .WriteEndElement()
                .WriteStartElement("DB1TableName2")
                .WriteString(DBTableName2)
                .WriteEndElement()
                .WriteStartElement("DB1TableName3")
                .WriteString(DBTableName3)
                .WriteEndElement()
                .WriteStartElement("DB1TableName4")
                .WriteString(DBTableName4)
                .WriteEndElement()
                ' The end of this person.
                .WriteEndElement()
                ' Close the XmlTextWriter.
                .WriteEndDocument()
                .Close()
            End With
            Response.Write("XML file saved.")
        End If
    End Sub
End Class




Tag : .NET, VB.NET







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-07-07 10:37:15 By : omyam001 View : 1968 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code ซับซ้อนนิดหนึ่งน่ะครับ

Code (VB.NET)
For Each desc In From element In catalog.<Catalog>.<Book>.<Description>
  ' Replace and preserve inner XML.
  desc.ReplaceWith(<Abstract><%= desc.Nodes %></Abstract>)
Next 

For Each price In From element In catalog.<Catalog>.<Book>.<Price>
  ' Replace with text value.
  price.ReplaceWith(<MSRP><%= price.Value %></MSRP>)
Next


Code
https://msdn.microsoft.com/en-us/library/bb918016.aspx
https://support.microsoft.com/en-us/kb/301233







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-07-11 10:15:44 By : mr.win
 


 

No. 2



โพสกระทู้ ( 90 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-07-12 16:28:28 By : omyam001
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ถามเรื่องการ write ข้อมูลลง xml โดยใช้ภาษา VB.net
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่