473,595 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How best to keep data set and db in synch

Rob
I have a form where the user may see a matrix of data in a grid (populated
via a dataset). If the user wishes to add a new row of data, they click a
button and a new form opens where the user may enter data into each
textbox, then click the add button when finished. At this point a stored
procedure is run which inserts the new row into the database (not the
dataset), given that the row is not a duplicate and the contents of each
text box are valid.

Now that the data resides in the database (via the sp), how best to update
the dataset ?
- Clear and fill OR
- add the new row to the dataset via code

How do most people accomplish this in vb.net ?

Is this a pretty common approach (use stored procs) instead of the ".update"
method ?

Thanks !
Dec 26 '05 #1
5 2594
I add the record to the Dataset first then do an Update using the
dataadaptor. If there is an error, I can then cancel the change the dataset.
This insures they are in sync.
--
Dennis in Houston
"Rob" wrote:
I have a form where the user may see a matrix of data in a grid (populated
via a dataset). If the user wishes to add a new row of data, they click a
button and a new form opens where the user may enter data into each
textbox, then click the add button when finished. At this point a stored
procedure is run which inserts the new row into the database (not the
dataset), given that the row is not a duplicate and the contents of each
text box are valid.

Now that the data resides in the database (via the sp), how best to update
the dataset ?
- Clear and fill OR
- add the new row to the dataset via code

How do most people accomplish this in vb.net ?

Is this a pretty common approach (use stored procs) instead of the ".update"
method ?

Thanks !

Dec 26 '05 #2
Rob
Dennis,

Thanks for responding... I was under the impression that the best way to
update Sql server was to use stored procedures... almost exclusively if
possible... is that the wrong way to think ?

Rob
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:9E******** *************** ***********@mic rosoft.com...
I add the record to the Dataset first then do an Update using the
dataadaptor. If there is an error, I can then cancel the change the
dataset.
This insures they are in sync.
--
Dennis in Houston
"Rob" wrote:
I have a form where the user may see a matrix of data in a grid
(populated
via a dataset). If the user wishes to add a new row of data, they click
a
button and a new form opens where the user may enter data into each
textbox, then click the add button when finished. At this point a
stored
procedure is run which inserts the new row into the database (not the
dataset), given that the row is not a duplicate and the contents of each
text box are valid.

Now that the data resides in the database (via the sp), how best to
update
the dataset ?
- Clear and fill OR
- add the new row to the dataset via code

How do most people accomplish this in vb.net ?

Is this a pretty common approach (use stored procs) instead of the
".update"
method ?

Thanks !

Dec 26 '05 #3
I certainly am not a database expert but I would think that if you are just
adding a record, then adding it to the DataSet then using the DataAdaptor's
Update method would be the easiest and be sure to keep them in sync.

There is probably a way to add a row to the database then get that latest
row and add it to the dataset but I don't know it.
--
Dennis in Houston
"Rob" wrote:
Dennis,

Thanks for responding... I was under the impression that the best way to
update Sql server was to use stored procedures... almost exclusively if
possible... is that the wrong way to think ?

Rob
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:9E******** *************** ***********@mic rosoft.com...
I add the record to the Dataset first then do an Update using the
dataadaptor. If there is an error, I can then cancel the change the
dataset.
This insures they are in sync.
--
Dennis in Houston
"Rob" wrote:
I have a form where the user may see a matrix of data in a grid
(populated
via a dataset). If the user wishes to add a new row of data, they click
a
button and a new form opens where the user may enter data into each
textbox, then click the add button when finished. At this point a
stored
procedure is run which inserts the new row into the database (not the
dataset), given that the row is not a duplicate and the contents of each
text box are valid.

Now that the data resides in the database (via the sp), how best to
update
the dataset ?
- Clear and fill OR
- add the new row to the dataset via code

How do most people accomplish this in vb.net ?

Is this a pretty common approach (use stored procs) instead of the
".update"
method ?

Thanks !


Dec 27 '05 #4
Rob
Here is how I am doing it in one case...

I have a matrix of data that is visible to the user (a dataset load)... if
they want to add data to this matrix they are taken to an "Add Data" form...
as they enter each row, it is validated and passed directly to the db via
stored proc, when they are done entering new rows (which now reside in the
db), on reactivation of the previous form (the form contining the matrix), I
clear the dataset and refresh it directly with data from the db.... that
sound ok ? Any drawbacks ?

"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:6B******** *************** ***********@mic rosoft.com...
I certainly am not a database expert but I would think that if you are just
adding a record, then adding it to the DataSet then using the
DataAdaptor's
Update method would be the easiest and be sure to keep them in sync.

There is probably a way to add a row to the database then get that latest
row and add it to the dataset but I don't know it.
--
Dennis in Houston
"Rob" wrote:
Dennis,

Thanks for responding... I was under the impression that the best way to
update Sql server was to use stored procedures... almost exclusively if
possible... is that the wrong way to think ?

Rob
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:9E******** *************** ***********@mic rosoft.com...
>I add the record to the Dataset first then do an Update using the
> dataadaptor. If there is an error, I can then cancel the change the
> dataset.
> This insures they are in sync.
> --
> Dennis in Houston
>
>
> "Rob" wrote:
>
>> I have a form where the user may see a matrix of data in a grid
>> (populated
>> via a dataset). If the user wishes to add a new row of data, they
>> click
>> a
>> button and a new form opens where the user may enter data into each
>> textbox, then click the add button when finished. At this point a
>> stored
>> procedure is run which inserts the new row into the database (not the
>> dataset), given that the row is not a duplicate and the contents of
>> each
>> text box are valid.
>>
>> Now that the data resides in the database (via the sp), how best to
>> update
>> the dataset ?
>> - Clear and fill OR
>> - add the new row to the dataset via code
>>
>> How do most people accomplish this in vb.net ?
>>
>> Is this a pretty common approach (use stored procs) instead of the
>> ".update"
>> method ?
>>
>> Thanks !
>>
>>
>>


Dec 27 '05 #5
Rob,

For some seems to be magic around a stored procedure, beside some effects it
is nothing else than a text command. It is got at the server instead given
as a text and compiled when it is needed.

A dataset and a database is (almost) never in synch. That is exactly what
optimistic concurrency and disconnected processing means. (Optimistic
concurrency means that the change that another user updates the information
meanwhile the data is in the dataset is low. However it has to be checked if
it is not protected in other ways).

For disctonnect you can think that you have a dataset in a PDA, that you
update once a week. That is (if there is not only one user) never in Synch
with the server.

For updating a dataset are a lot of methods. See here a new sample (for
VS2005) on our website, it is a little bit else than the regular ways.

http://www.vb-tips.com/default.aspx?...e-22eaaebb2723

I hope this helps,

Cor
Dec 28 '05 #6

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

Similar topics

15
7645
by: Joshua Beall | last post by:
Hi All, What is the best way to use a cookie to remember a logged in user? Would you store the username and password in two separate cookies? Should the password be plain text? Hashed? Not there at all? Any feedback would be helpful. Thanks! -Josh
5
2879
by: steve | last post by:
Hi, I finally figured out the best way to synch local and remote script folders, containing many php script files. What I used to do before was try to ftp all the changed files, etc. which was tedious and often broke. It was also very slow. What I do now is to pkzip the folder up, ftp the pkzip’ed data to remote, and then unzip it there, which recreates the directories and files.
8
1434
by: JohnFol | last post by:
I have a requirement to run some code on a server. The purpose of the code is purely to process data between an MS SQL box and a remote Oracle box. It has no UI, and needs no user intervention to run. The 2nd part of the requirement is to have a UI that will allow an operator to view the progress / current status of the processing. Even if the UI is not loaded, the processing must continue. I have a few ideas on how to tackle this, but...
0
2492
by: andrew | last post by:
Scenario description - We have two Oracle DB's A & B. Both DB's have a table test1 (customerid varchar2(50, val number). The idea is that for every customer id, the counter (stored in val) increases. Whenever we send a file to the customer, we tag/identify it with a counter value. This is for verification on the customer side that they have received all files by checking for a break in the counter. We have many customers in the table, each...
3
1681
by: BPDudeMan | last post by:
Hi There, I've got one table that is constantly being added to (every few seconds). I've got a bunch of users that need to report from this table. What's the best way to setup the tables? Create a second table and updates it with tblLive data every let's say 15 minutes and then report off of that? Is there a way to synch tables that doesn't have a lot of over head? Or just report off of tblLive directly? Any suggestions would be...
3
1393
by: Rob | last post by:
Rather new to vb.net... I am wondering if the following is possible and sounds reasonable... Can connection objects and datasets be defined once (at program load) and be available for the life of the program ? Posssible ? Bad idea ? Over simplistic ? Regarding Connections... I am not saying that the conncetion should be left open, just defined... in
2
1879
by: piggy | last post by:
Hello, I have an application and when a user clicks on it, it first will check to see if the there is a new version in the server using files synch (ftp). If there is then download the new files to the client machine. Clickonce won't work for me so i have tried to see if files synch will work. Thanks for your help.
2
16792
yashg
by: yashg | last post by:
I am building a data backup application in C# using Sockets. It has a server component and a client component. The client is going to upload files to the server through TCP sockets. I've got all figured out and have been able to transfer files between client and server. Now I have some doubts about which is the best method to transfer a file? Option 1 - I use the built in Socket.BeginSendFile (I am using async calls) to transfer a file. Option 2...
1
1511
by: Patrick A | last post by:
All, I have an Access DB. On a nightly basis, I want to look at an Other DB (not Access, but SQL) and: + Add any new records from Other.Clients into Access.Clients Is this something I should use a "tool" (SQL Data Compare, SqlSync, etc.) to do, or could I pull this off reliably every night just using SQL from the query I could construct to do the job from inside my
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6674
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2391
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.