Hello,
I am having trouble inserting data from a XML file into a table in a SQL data base. The worst thing is it isn't coming up with an error but nothing is being inserted into the database
Here is the condensed version of the XML code I am using to test with:
<?xml version="1.0" encoding="UTF-8"?>
<propertyList date="2009-01-01-12:30:00" username="xmluser" password="xmlpassword">
<!-- Current listing -->
<residential modTime="2009-01-01-12:30:00" status="current">
<agentID>XNWXNW</agentID>
<uniqueID>ABCD1234</uniqueID>
<authority value="exclusive"/>
<underOffer value="no"/>
<listingAgent>
<name>Mr. John Doe</name>
<telephone type="BH">05 1234 5678</telephone>
<email>jdoe@somedomain.com.au</email>
</listingAgent>
<listingAgent>
<name>Mrs Jane Dow</name>
<telephone type="BH">05 1234 5678</telephone>
<email>janedoe@somedomain.com.au</email>
</listingAgent>
</residential>
</propertyList>
And the "insert" code:
Imports System.IO
Imports System.Data
Imports System.Xml
Imports System.Data.SqlClient
Partial Class InsertXML
Inherits System.Web.UI.Page
Private Sub InsertXML()
Dim connetionString As String
Dim command As SqlCommand
Dim adpter As New SqlDataAdapter
Dim ds As New DataSet
Dim xmlFile As XmlReader
Dim sql As String
Dim name As String
Dim telephone As String
Dim email As Double
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))
xmlFile = XmlReader.Create("sample1.xml", New XmlReaderSettings())
ds.ReadXml(xmlFile)
Dim i As Integer
myConnection.Open()
For i = 0 To ds.Tables(0).Rows.Count - 1
name = ds.Tables(0).Rows(i).Item(0)
telephone = ds.Tables(0).Rows(i).Item(1)
email = ds.Tables(0).Rows(i).Item(2)
sql = "insert into Realestate values(" & name & ",'" & telephone & "'," & email & ")"
command = New SqlCommand(sql, myConnection)
adpter.InsertCommand = command
adpter.InsertCommand.ExecuteNonQuery()
Next
myConnection.Close()
End Sub
End Class
As I said there isn't any error coming up so im completely stumped...
Any help would be great.