473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Insert data from a Dataset into a SQL Database

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
Nov 12 '05 #1
0 3603

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
4
by: authorking | last post by:
I use the following code to insert a data record in to a datatable of an access database.But every time I execute the command, there will rise an exception and the insert operation can't be...
1
by: authorking | last post by:
I create the databse with the follwing code. I really don't know why the insert operation can't be completed. databse creation code: ADOX.CatalogClass cat = new ADOX.CatalogClass();//define a Jet...
4
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). ...
0
by: Eustice Scrubb | last post by:
In line coding problem. Here's my code: <script language="VB" runat="server"> Dim myConnection As SqlConnection Sub Page_Load(Src As Object, e As EventArgs) ' Create a connection to the SQL...
4
by: chambersdon | last post by:
I have an application that needs to insert nulls into the database and I don't seem to be able to do this. I am currently trying to do this with a Typed DataSet but I can't seem to Insert Nulls...
6
by: Marcel Hug | last post by:
Hi all ! I have a table in my database, which has 3 attributes. IDFailureControl, ControlDate and ControlVersion. In the following function I test, if the date of today allready exists. Then I...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
3
by: iKiLL | last post by:
Hi all I am having problems getting my SqlCeDataAdapter to Update the SQL Mobile Data base. i am using C# CF2. I have tried this a number of different ways. Starting with the command builder...
13
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.