473,378 Members | 1,347 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,378 software developers and data experts.

Create a offline database

Hi,
I am trying to create an offline database in VB.NET 2005, both the online and offline database use SQL Server 2005.
The code I am using seems to run OK with out an exception the DATASET has the records added, but the UPDATE will not update the offline database. (The offline database is empty before I start)

Q1) what am I doing wrong?
Q2) is there a better way of coping data to an offline SQL database?

My code
Expand|Select|Wrap|Line Numbers
  1.  
  2. Try
  3.     da = New SqlDataAdapter(SQLcmd)
  4.     conSQL.Open()
  5.     da.Fill(dsOffLine, "TableName")
  6.     dtOffLine= dsOffLine.Tables(0)
  7.     Dim dsRow As DataRow
  8.     Dim dsRowB As DataRow
  9.  
  10. 'Online DS loaded earlier
  11.     For Each dsRow In frmMain.dsOnLine.Tables("TableName").Rows
  12.         dsRowB = dtOffLine.NewRow()
  13.         dsRowB.ItemArray = dsRow.ItemArray
  14.         dtOffLine.Rows.Add(dsRowB)
  15.         ''    Tried this instead of the above three rows
  16.          '     dtOffLine.ImportRow(dsRow)
  17.    Next
  18.  
  19.      dtOffLine.AcceptChanges()
  20.      da.Update(dsOffLine, "TableName")
  21.      conSQL.Close()
  22. Catch ex As Exception
  23.      MsgBox(ex.ToString)
  24. End Try
  25.  

Thanks

Eric
May 17 '07 #1
2 1980
Ok I have resolved the issue with two lines of code.

Remove line 18
Expand|Select|Wrap|Line Numbers
  1. dtOffLine.AcceptChanges()
  2.  
And add a line after line 2

Expand|Select|Wrap|Line Numbers
  1. Dim builder As SqlCommandBuilder = New SqlCommandBuilder(da) 
  2.  
Thanks
May 18 '07 #2
kenobewan
4,871 Expert 4TB
Well done! Thanks for sharing the solution.
May 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: NohaKhalifa | last post by:
Dear All ; I have a web site and i made it's administration offline using asp . I want after I fill a data in the offline database, onclick a button this data sent online . The problem is...
1
by: Moti | last post by:
Hello, I am trying to check the integrity of SQL database. The 'problem' with SQL server is that it's fixing the DB automatically after restore so I need a way to do it offline, much like using...
0
by: moko | last post by:
This is a bit long-winded. Can somebody read thru these 2 use cases, and tell me if it is feasible ? :- Use Case : Replication before Offline Synch Scenario 1 : Oracle Server , MSDE client ...
2
by: Buck Turgidson | last post by:
I have an SAP development system running on Linux. It is not a critical system, but I would like a restore-able backup. I have taken an offline backup, but I am unable to restore it. I am...
1
by: intl04 | last post by:
I am getting strange print-related error messages when trying to create (not print!) reports. For example, when I click 'new' to create a report then choose 'design view', I get an error message...
2
by: John | last post by:
Hi I need to develop an app in vb 2005 which can work in both offline and online modes and will be running on client laptops. I have listened to the following web cast; ...
3
by: Alex | last post by:
Hello, I am running an Access 2003 database, quite modest in size, that is used by upwards of 5 users. I need to modify the database such that these users can work simultaneously and, in some...
0
by: prashanthdb2 | last post by:
Hi, Im new to db2. Im using db2 ese 9.1 (fix pack 1) on SLES 9.0 32 bit. I have single instance on three logical nodes 0,1,2. i have cofigured userexit - on, logretain - on, trackmod - on. ...
10
by: Michael Hoffmann | last post by:
Hello, I hope this doesn't come across as totally newbieish, but I've been searching the web and the IBM docs until smoke is coming out of my head. Scenario: We are trying to take primitive...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.