R
Ralph Hanan
Hi guys my name is Ralph, i am kinda new to this so please bear with
me.
I have written a .net web service which accepts a stream of data
see relevent source code).
Public Function PutBondInfo(ByVal data As String) As DataSet
Try
Dim zh As New ZipHelper
Dim sz As String
Dim cn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim xSet As New DataSet
Dim sSql As String
Dim mySerializer As XmlSerializer = New
XmlSerializer(ds.GetType())
cn = New
SqlConnection("server=HLSQL;uid=test;pwd=;database=test")
cn.Open()
da = New SqlDataAdapter("SELECT * FROM BondStatus", cn)
'da.TableMappings.Add("BondStatus", "NewDataSet")
sz = zh.Decompress(data)
zh = Nothing
da.FillSchema(ds, SchemaType.Mapped, "BondStatus")
'da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds, "BondStatus")
Dim st As New MemoryStream(Encoding.UTF8.GetBytes(sz))
' Create the object from the xml file
xSet = CType(mySerializer.Deserialize(st), DataSet)
xSet.Tables(0).TableName = ds.Tables(0).TableName
ds.Merge(xSet, False, System.Data.MissingSchemaAction.Add)
'ds.AcceptChanges()
Dim SqlCB As SqlCommandBuilder = New SqlCommandBuilder(da)
da.Update(ds, "BondStatus")
st.Close()
da.Dispose()
SqlCB.Dispose()
cn.Close()
Return ds
Catch ex As Exception
ex.Message().ToString()
End Try
End Function
This data is compressed.I decompress the data and receive the xml
which is then
deserialized into a dataset. this part works great no problems. My
problem is then taking that dataset and pushing the data into a table
on my SQL server. The elements in the xml and the field names of my
SQL table 'BondStatus'
are exactly the same. The table names are different the xml has
'Table' as its table name and so on. As you can see from the code I
have tried table mappings, assigns, merges etc with no luck.
Ladies and gents if anyone has a clue as to what I am doing and can
help me, it would be appreciated.
Thanks in advance
Ralph
me.
I have written a .net web service which accepts a stream of data
see relevent source code).
Public Function PutBondInfo(ByVal data As String) As DataSet
Try
Dim zh As New ZipHelper
Dim sz As String
Dim cn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim xSet As New DataSet
Dim sSql As String
Dim mySerializer As XmlSerializer = New
XmlSerializer(ds.GetType())
cn = New
SqlConnection("server=HLSQL;uid=test;pwd=;database=test")
cn.Open()
da = New SqlDataAdapter("SELECT * FROM BondStatus", cn)
'da.TableMappings.Add("BondStatus", "NewDataSet")
sz = zh.Decompress(data)
zh = Nothing
da.FillSchema(ds, SchemaType.Mapped, "BondStatus")
'da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds, "BondStatus")
Dim st As New MemoryStream(Encoding.UTF8.GetBytes(sz))
' Create the object from the xml file
xSet = CType(mySerializer.Deserialize(st), DataSet)
xSet.Tables(0).TableName = ds.Tables(0).TableName
ds.Merge(xSet, False, System.Data.MissingSchemaAction.Add)
'ds.AcceptChanges()
Dim SqlCB As SqlCommandBuilder = New SqlCommandBuilder(da)
da.Update(ds, "BondStatus")
st.Close()
da.Dispose()
SqlCB.Dispose()
cn.Close()
Return ds
Catch ex As Exception
ex.Message().ToString()
End Try
End Function
This data is compressed.I decompress the data and receive the xml
which is then
deserialized into a dataset. this part works great no problems. My
problem is then taking that dataset and pushing the data into a table
on my SQL server. The elements in the xml and the field names of my
SQL table 'BondStatus'
are exactly the same. The table names are different the xml has
'Table' as its table name and so on. As you can see from the code I
have tried table mappings, assigns, merges etc with no luck.
Ladies and gents if anyone has a clue as to what I am doing and can
help me, it would be appreciated.
Thanks in advance
Ralph