PC Review


Reply
Thread Tools Rate Thread

copying dataset from asp.net webservice to local db

 
 
Aaron
Guest
Posts: n/a
 
      20th Nov 2003
Hi all,
I am trying to insert a whole dataset from my web service into a
SQLCE database. I am unsucessful so far. Any help is appreciated.
Here is what I have so far (the dataset is returned fine). I think my
problem lies in the fact that the rowstate is unchanged. I need it to
be add or even better yet, can it compare on its own??

Thanks, Aaron
-----------------------------------------------------------------------------

Public Sub SynchSQL2(ByVal ds As DataSet)
'connect locally to SQLCE
sqlConn = New SqlCeConnection(frmMain.connStr)
sqlConn.Open()
Dim dtSQL As DataTable
Dim dtCE As DataTable
Dim ds2 As DataSet = New DataSet
Dim cb As SqlCeCommandBuilder
Try

Dim dsupdate As New DataSet
'this is one table I am trying to "synch"
sqlDA = New SqlCeDataAdapter("select id,branch from
branch", sqlConn)

'create the commands
cb = New SqlCeCommandBuilder(sqlDA)
'set dataadapter insert to created command
sqlDA.InsertCommand = cb.GetInsertCommand()

sqlDA.Update(ds, "branch")

Catch ex As Exception
MsgBox(ex.Message)
End Try
 
Reply With Quote
 
 
 
 
William Ryan
Guest
Posts: n/a
 
      20th Nov 2003
Yes, if you don't change the data, then it won't be submitted to the DB.
You can call DataSet.HasChanges to test this, but from the code below, there
aren't any changes.

Without the commandbuilder though, you could iterate through the datarows
and submit them on your own (if you want everything to be added to the DB).
I'm guessin g that your ultimate goal is to query the WebService and get all
of that Data into your Database. You could also check beforehand to see if
it exists and compare states and all of that jazz.

I also think you could just walk the Rows Collection and set the Rowstate
manually, once this happens the commandbuilder should do it's thing. (I
haven't done it personally, but I'm pretty sure you can set the rowstate and
if so, it'll work).

HTH,

Bill
"Aaron" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
> I am trying to insert a whole dataset from my web service into a
> SQLCE database. I am unsucessful so far. Any help is appreciated.
> Here is what I have so far (the dataset is returned fine). I think my
> problem lies in the fact that the rowstate is unchanged. I need it to
> be add or even better yet, can it compare on its own??
>
> Thanks, Aaron
> --------------------------------------------------------------------------

---
>
> Public Sub SynchSQL2(ByVal ds As DataSet)
> 'connect locally to SQLCE
> sqlConn = New SqlCeConnection(frmMain.connStr)
> sqlConn.Open()
> Dim dtSQL As DataTable
> Dim dtCE As DataTable
> Dim ds2 As DataSet = New DataSet
> Dim cb As SqlCeCommandBuilder
> Try
>
> Dim dsupdate As New DataSet
> 'this is one table I am trying to "synch"
> sqlDA = New SqlCeDataAdapter("select id,branch from
> branch", sqlConn)
>
> 'create the commands
> cb = New SqlCeCommandBuilder(sqlDA)
> 'set dataadapter insert to created command
> sqlDA.InsertCommand = cb.GetInsertCommand()
>
> sqlDA.Update(ds, "branch")
>
> Catch ex As Exception
> MsgBox(ex.Message)
> End Try



 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      20th Nov 2003
Take a look at ImportDataSet sample at
http://www.alexfeinman.com/samples.asp
In it the dataset is loaded from disk (xml file) and is written via update
into SQL CE table. To use it with your web service make the web service to
return the DataSet variable and use this return value instead of loading
Dataset from disk.

"Aaron" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
> I am trying to insert a whole dataset from my web service into a
> SQLCE database. I am unsucessful so far. Any help is appreciated.
> Here is what I have so far (the dataset is returned fine). I think my
> problem lies in the fact that the rowstate is unchanged. I need it to
> be add or even better yet, can it compare on its own??
>
> Thanks, Aaron
> --------------------------------------------------------------------------

---
>
> Public Sub SynchSQL2(ByVal ds As DataSet)
> 'connect locally to SQLCE
> sqlConn = New SqlCeConnection(frmMain.connStr)
> sqlConn.Open()
> Dim dtSQL As DataTable
> Dim dtCE As DataTable
> Dim ds2 As DataSet = New DataSet
> Dim cb As SqlCeCommandBuilder
> Try
>
> Dim dsupdate As New DataSet
> 'this is one table I am trying to "synch"
> sqlDA = New SqlCeDataAdapter("select id,branch from
> branch", sqlConn)
>
> 'create the commands
> cb = New SqlCeCommandBuilder(sqlDA)
> 'set dataadapter insert to created command
> sqlDA.InsertCommand = cb.GetInsertCommand()
>
> sqlDA.Update(ds, "branch")
>
> Catch ex As Exception
> MsgBox(ex.Message)
> End Try



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Dataset from webservice and update local sql server!! Jay Balapa Microsoft ADO .NET 1 9th Mar 2006 09:48 PM
Excel 2003: Grabbing a dataset from a webservice and then sending to a webservice? gjn Microsoft Excel Programming 1 7th Oct 2005 04:00 PM
webservice & dataset BS Microsoft VB .NET 0 17th May 2004 08:23 PM
Dataset and webservice Richard Microsoft Dot NET Compact Framework 2 10th Sep 2003 04:36 PM
webservice class inherite DataSet and client generate the force dataset issues miller chen Microsoft C# .NET 0 18th Jul 2003 09:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:53 AM.