G
Graeme Richardson
Hi, I have the coded the following in an attempt to get xml data into an
SQLCe database. The code executes without error, but the table,
tlkpBaitSpecies, remains empty.
Try
Dim da As New SqlCeDataAdapter
Dim cmdInsert As SqlCeCommand
' msqlConnection (As SqlCeConnection) is open.
da.SelectCommand = New SqlCeCommand("SELECT uidBaitSpecies, CommonName
FROM tlkpBaitSpecies", msqlConnection)
cmdInsert = New SqlCeCommand("INSERT INTO tlkpBaitSpecies
(uidBaitSpecies, CommonName) " & _
"VALUES (@uidBaitSpecies, @CommonName) ",
msqlConnection)
cmdInsert.Parameters.Add("@uidBaitSpecies", SqlDbType.NVarChar, 2,
"uidBaitSpecies")
cmdInsert.Parameters.Add("@CommonName", SqlDbType.NVarChar, 50,
"CommonName")
da.InsertCommand = cmdInsert
Dim ds As New DataSet
da.Fill(ds) ' Probably nonsense
ds.ReadXml(vstrXMLFile) ' xml and xsd file exist
ds.AcceptChanges()
da.Update(ds)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
I'm sure the problem is in configuring the DataSet, but can't find an
example on how to do this.
Please suggest a way forward.
I tried appending row by row from xml file but found that data anomalies
(e.g. quotes in string, Null values, etc) will always be a problem.
Thanks, Graeme
SQLCe database. The code executes without error, but the table,
tlkpBaitSpecies, remains empty.
Try
Dim da As New SqlCeDataAdapter
Dim cmdInsert As SqlCeCommand
' msqlConnection (As SqlCeConnection) is open.
da.SelectCommand = New SqlCeCommand("SELECT uidBaitSpecies, CommonName
FROM tlkpBaitSpecies", msqlConnection)
cmdInsert = New SqlCeCommand("INSERT INTO tlkpBaitSpecies
(uidBaitSpecies, CommonName) " & _
"VALUES (@uidBaitSpecies, @CommonName) ",
msqlConnection)
cmdInsert.Parameters.Add("@uidBaitSpecies", SqlDbType.NVarChar, 2,
"uidBaitSpecies")
cmdInsert.Parameters.Add("@CommonName", SqlDbType.NVarChar, 50,
"CommonName")
da.InsertCommand = cmdInsert
Dim ds As New DataSet
da.Fill(ds) ' Probably nonsense
ds.ReadXml(vstrXMLFile) ' xml and xsd file exist
ds.AcceptChanges()
da.Update(ds)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
I'm sure the problem is in configuring the DataSet, but can't find an
example on how to do this.
Please suggest a way forward.
I tried appending row by row from xml file but found that data anomalies
(e.g. quotes in string, Null values, etc) will always be a problem.
Thanks, Graeme