Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a PPC app that I am transferring about 300 records from an SQL connection to my SQLCE database. Currently I am filling a datareader, doing the following.

 

Do while sqlDR.read

'Write record to sqlCE database.

loop

 

This is painfully slow but it works, I do not want to do anything fancy like syncing to sql server through IIS. Is there a way to fill a datareader, then pass said datareader object over to the sqlCE database. I am sure it will still take a moment or two, but I am also sure it will be more efficent than a record by record loop.

 

Any thoughts or examples?

Thank you.

  • *Experts*
Posted

If you only have 300 records, I'd use a DataSet and DataAdapter. Read in 300 records into your DataSet and use the DataAdapter to insert the data into the other DB.

 

If you can, I'd use the DTS (data transformation services) provided by SQL Server to do this transfer. You can setup a package to do the transfer and kick that off programmatically, if needed.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
If you only have 300 records, I'd use a DataSet and DataAdapter. Read in 300 records into your DataSet and use the DataAdapter to insert the data into the other DB.

 

If you can, I'd use the DTS (data transformation services) provided by SQL Server to do this transfer. You can setup a package to do the transfer and kick that off programmatically, if needed.

 

-ner

I like the dataset/dataadapter idea I will give that a try, my biggest problem with DTS is that I am trying to go from MSSQL full to sqlCE, not as clean as one might expect, anyway I will give the adapter/set a try.

 

Now, I have worked very little with these items, if I build the dataset, then link the adapter to an identical table in another database will it update?

Posted

Here's a quick update. This is the code I am using, but it does not work, it doesn't fire off any errors to the contrary however. Any assistance would be great.

 

Private Sub TransferSQLtoCE

dbc.DBSource.Open()

Dim ssceconn As New SqlCeConnection(_DataSource)

 

Dim command As String = "SELECT company, phone, address, city, state, zipcode FROM pt6cs_user where user_type='EndUser'"

Dim DS As New DataSet("CustomerData")

Dim adaptorSQL As New System.Data.SqlClient.SqlDataAdapter(command, dbc.DBSource)

adaptorSQL.Fill(DS, "customers")

adaptorSQL.Dispose()

 

da.InsertCustomer(True)

 

command = "SELECT company, phone, address, city, state, zipcode FROM Customers"

ssceconn.Open()

Dim adaptorCE As New System.Data.SqlServerCe.SqlCeDataAdapter(command, ssceconn)

ssceconn.Close()

 

adaptorCE.Update(DS, "customers")

adaptorCE.Dispose()

 

MessageBox.Show("Completed Loading Customers into the SQL Database", "Customer Refresh")

dbc.DBSource.Close()

End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...