I'm creating DataSet, then 2 DataTables, then DataRelation between those
DataTables.
I populate DataTables with DataAdapters. Data from each table is displayed
in Grids.
For display everything works fine - if I change the current record in the
Parent grid then the Child grid displays records related to the Parent.
In order to update any record in both Parent and Child underlying
datasources (SQL Server tables) I need to know ID of the record.
What is the proper way to get an ID (it exists in the DataTable, in
BindingSource)? I just do not know how to get it? The only way I found (I
don't like it) is to bind ID field to TextBox control and then when I need
ID I get it from the bound TextBox.
Thank you
vovan 7 2148
Vovan,
I cannot find a nice sample at the moment, however you need the datarowstate
to get the changed rows per table in a copy of your dataset
Those you update to your database in the sequence
childs deleted
parents deleted
parents added
childs added
parents updated
childs updated
However you use for that the dataadapter and not the executenonquery as I
get the idea you want to do.
If everything goes right than you have to do an acceptchanges at the end.
Quickly written in this messages so watch typos or whatever.
Cor
"vovan" <so*****@vovan. comschreef in bericht
news:eT******** *****@TK2MSFTNG P06.phx.gbl...
I'm creating DataSet, then 2 DataTables, then DataRelation between those
DataTables.
I populate DataTables with DataAdapters. Data from each table is displayed
in Grids.
For display everything works fine - if I change the current record in the
Parent grid then the Child grid displays records related to the Parent.
In order to update any record in both Parent and Child underlying
datasources (SQL Server tables) I need to know ID of the record.
What is the proper way to get an ID (it exists in the DataTable, in
BindingSource)? I just do not know how to get it? The only way I found (I
don't like it) is to bind ID field to TextBox control and then when I need
ID I get it from the bound TextBox.
Thank you
vovan
Thank you Cor
First of all, I need to use ExecuteNoneQuer y because I'm working on upgrade
of VB6 application which uses tons of existing Stored Procedures and I was
thinking that using existing SPs will decrease the time of developing.
The second reason is I couldn't find any sample which uses your approach and
SPs at the same time. Everything I found so far with Update/Insert/Delete
operations was with SQL codes in the body of the program with some question
marks in the bodies of statements. Unfortunately I couldn't understand those
codes.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:OE******** ******@TK2MSFTN GP03.phx.gbl...
Vovan,
I cannot find a nice sample at the moment, however you need the
datarowstate to get the changed rows per table in a copy of your dataset
Those you update to your database in the sequence
childs deleted
parents deleted
parents added
childs added
parents updated
childs updated
However you use for that the dataadapter and not the executenonquery as I
get the idea you want to do.
If everything goes right than you have to do an acceptchanges at the end.
Quickly written in this messages so watch typos or whatever.
Cor
"vovan" <so*****@vovan. comschreef in bericht
news:eT******** *****@TK2MSFTNG P06.phx.gbl...
>I'm creating DataSet, then 2 DataTables, then DataRelation between those DataTables. I populate DataTables with DataAdapters. Data from each table is displayed in Grids. For display everything works fine - if I change the current record in the Parent grid then the Child grid displays records related to the Parent. In order to update any record in both Parent and Child underlying datasources (SQL Server tables) I need to know ID of the record. What is the proper way to get an ID (it exists in the DataTable, in BindingSource) ? I just do not know how to get it? The only way I found (I don't like it) is to bind ID field to TextBox control and then when I need ID I get it from the bound TextBox.
Thank you vovan
Vovan,
It is almost impossible to show samples with stored procedures.
However an text procedure is good written nowhere different from a stored
procedure while such a procedure is just by copy and paste to bring to a
stored procedure and than the only thing that has be changed is the adding
of the property http://msdn2.microsoft.com/en-us/lib...pe(vs.80).aspx
Cor
"vovan" <so*****@vovan. comschreef in bericht
news:O9******** ******@TK2MSFTN GP05.phx.gbl...
Thank you Cor
First of all, I need to use ExecuteNoneQuer y because I'm working on
upgrade of VB6 application which uses tons of existing Stored Procedures
and I was thinking that using existing SPs will decrease the time of
developing.
The second reason is I couldn't find any sample which uses your approach
and SPs at the same time. Everything I found so far with
Update/Insert/Delete operations was with SQL codes in the body of the
program with some question marks in the bodies of statements.
Unfortunately I couldn't understand those codes.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:OE******** ******@TK2MSFTN GP03.phx.gbl...
>Vovan,
I cannot find a nice sample at the moment, however you need the datarowstate to get the changed rows per table in a copy of your dataset
Those you update to your database in the sequence childs deleted parents deleted parents added childs added parents updated childs updated
However you use for that the dataadapter and not the executenonquery as I get the idea you want to do.
If everything goes right than you have to do an acceptchanges at the end.
Quickly written in this messages so watch typos or whatever.
Cor
"vovan" <so*****@vovan. comschreef in bericht news:eT******* ******@TK2MSFTN GP06.phx.gbl...
>>I'm creating DataSet, then 2 DataTables, then DataRelation between those DataTables. I populate DataTables with DataAdapters. Data from each table is displayed in Grids. For display everything works fine - if I change the current record in the Parent grid then the Child grid displays records related to the Parent. In order to update any record in both Parent and Child underlying datasources (SQL Server tables) I need to know ID of the record. What is the proper way to get an ID (it exists in the DataTable, in BindingSource )? I just do not know how to get it? The only way I found (I don't like it) is to bind ID field to TextBox control and then when I need ID I get it from the bound TextBox.
Thank you vovan
As I know from my VB6/SQL Server experience there is a huge difference in
performance between SPs and build in code.
The same body of some procedures and the code imbedded into VB application.
The time of execution for an SP is a portion of a second, the code from VB
takes 10 seconds. It's due to the need to compile the embedded code first.
SP is already compiled.
Maybe it works differently with VB2005? I don't know.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Vovan,
It is almost impossible to show samples with stored procedures.
However an text procedure is good written nowhere different from a stored
procedure while such a procedure is just by copy and paste to bring to a
stored procedure and than the only thing that has be changed is the adding
of the property
http://msdn2.microsoft.com/en-us/lib...pe(vs.80).aspx
Cor
"vovan" <so*****@vovan. comschreef in bericht
news:O9******** ******@TK2MSFTN GP05.phx.gbl...
>Thank you Cor First of all, I need to use ExecuteNoneQuer y because I'm working on upgrade of VB6 application which uses tons of existing Stored Procedures and I was thinking that using existing SPs will decrease the time of developing. The second reason is I couldn't find any sample which uses your approach and SPs at the same time. Everything I found so far with Update/Insert/Delete operations was with SQL codes in the body of the program with some question marks in the bodies of statements. Unfortunatel y I couldn't understand those codes.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message news:OE******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Vovan,
I cannot find a nice sample at the moment, however you need the datarowstat e to get the changed rows per table in a copy of your dataset
Those you update to your database in the sequence childs deleted parents deleted parents added childs added parents updated childs updated
However you use for that the dataadapter and not the executenonquery as I get the idea you want to do.
If everything goes right than you have to do an acceptchanges at the end.
Quickly written in this messages so watch typos or whatever.
Cor
"vovan" <so*****@vovan. comschreef in bericht news:eT****** *******@TK2MSFT NGP06.phx.gbl.. . I'm creating DataSet, then 2 DataTables, then DataRelation between those DataTables. I populate DataTables with DataAdapters. Data from each table is displayed in Grids. For display everything works fine - if I change the current record in the Parent grid then the Child grid displays records related to the Parent. In order to update any record in both Parent and Child underlying datasource s (SQL Server tables) I need to know ID of the record. What is the proper way to get an ID (it exists in the DataTable, in BindingSourc e)? I just do not know how to get it? The only way I found (I don't like it) is to bind ID field to TextBox control and then when I need ID I get it from the bound TextBox.
Thank you vovan
Vovan,
There is only one SQL database server that uses compiled procedures. That is
the IBM DB2. Neither Oracle, Microsoft of whatever other does that (quoting
Frans Bouma for the non Microsoft versions).
SP's have in common a slightly better performance because that they don't
have to be loaded everytime, but don't think than in seconds, just parts of
seconds.
There are some advantages for the SP but that is for the oposite as well.
However, in common it are fairly tails.
Cor
"vovan" <so*****@vovan. comschreef in bericht
news:uz******** ******@TK2MSFTN GP02.phx.gbl...
As I know from my VB6/SQL Server experience there is a huge difference in
performance between SPs and build in code.
The same body of some procedures and the code imbedded into VB
application. The time of execution for an SP is a portion of a second, the
code from VB takes 10 seconds. It's due to the need to compile the
embedded code first. SP is already compiled.
Maybe it works differently with VB2005? I don't know.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>Vovan,
It is almost impossible to show samples with stored procedures.
However an text procedure is good written nowhere different from a stored procedure while such a procedure is just by copy and paste to bring to a stored procedure and than the only thing that has be changed is the adding of the property
http://msdn2.microsoft.com/en-us/lib...pe(vs.80).aspx
Cor
"vovan" <so*****@vovan. comschreef in bericht news:O9******* *******@TK2MSFT NGP05.phx.gbl.. .
>>Thank you Cor First of all, I need to use ExecuteNoneQuer y because I'm working on upgrade of VB6 application which uses tons of existing Stored Procedures and I was thinking that using existing SPs will decrease the time of developing. The second reason is I couldn't find any sample which uses your approach and SPs at the same time. Everything I found so far with Update/Insert/Delete operations was with SQL codes in the body of the program with some question marks in the bodies of statements. Unfortunate ly I couldn't understand those codes.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message news:OE****** ********@TK2MSF TNGP03.phx.gbl. .. Vovan,
I cannot find a nice sample at the moment, however you need the datarowsta te to get the changed rows per table in a copy of your dataset
Those you update to your database in the sequence childs deleted parents deleted parents added childs added parents updated childs updated
However you use for that the dataadapter and not the executenonquery as I get the idea you want to do.
If everything goes right than you have to do an acceptchanges at the end.
Quickly written in this messages so watch typos or whatever.
Cor
"vovan" <so*****@vovan. comschreef in bericht news:eT***** ********@TK2MSF TNGP06.phx.gbl. .. I'm creating DataSet, then 2 DataTables, then DataRelation between those DataTables. I populate DataTables with DataAdapters. Data from each table is displayed in Grids. For display everything works fine - if I change the current record in the Parent grid then the Child grid displays records related to the Parent. In order to update any record in both Parent and Child underlying datasourc es (SQL Server tables) I need to know ID of the record. What is the proper way to get an ID (it exists in the DataTable, in BindingSour ce)? I just do not know how to get it? The only way I found (I don't like it) is to bind ID field to TextBox control and then when I need ID I get it from the bound TextBox. > Thank you vovan > > >
I don't know, Cor.
I'm telling you what I met. Initially my application was written to work
with Access. Later Access was upgraded to SQL Server. No SPs were used right
after that. In a couple of years some screens begun to work pretty slow.
Using Debug.Print Now I found all buttle necks, I mean places in the code
where the application spends a significant time. Most of them were
populating recordsets via embedded SQL statements.
I was surprized with the result when I replaced the most slow part with SP.
Although I did not change statements logic (often I just moved the code into
the body of SP, added parameters etc), the speed encreased dramatically.
Maybe in theory SQL Server doesn't compile SP. But the result of using SPs
doesn't make me go back to embedded code.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Vovan,
There is only one SQL database server that uses compiled procedures. That
is the IBM DB2. Neither Oracle, Microsoft of whatever other does that
(quoting Frans Bouma for the non Microsoft versions).
SP's have in common a slightly better performance because that they don't
have to be loaded everytime, but don't think than in seconds, just parts
of seconds.
There are some advantages for the SP but that is for the oposite as well.
However, in common it are fairly tails.
Cor
"vovan" <so*****@vovan. comschreef in bericht
news:uz******** ******@TK2MSFTN GP02.phx.gbl...
>As I know from my VB6/SQL Server experience there is a huge difference in performance between SPs and build in code. The same body of some procedures and the code imbedded into VB application. The time of execution for an SP is a portion of a second, the code from VB takes 10 seconds. It's due to the need to compile the embedded code first. SP is already compiled. Maybe it works differently with VB2005? I don't know.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>Vovan,
It is almost impossible to show samples with stored procedures.
However an text procedure is good written nowhere different from a stored procedure while such a procedure is just by copy and paste to bring to a stored procedure and than the only thing that has be changed is the adding of the property
http://msdn2.microsoft.com/en-us/lib...pe(vs.80).aspx
Cor
"vovan" <so*****@vovan. comschreef in bericht news:O9****** ********@TK2MSF TNGP05.phx.gbl. .. Thank you Cor First of all, I need to use ExecuteNoneQuer y because I'm working on upgrade of VB6 application which uses tons of existing Stored Procedures and I was thinking that using existing SPs will decrease the time of developing. The second reason is I couldn't find any sample which uses your approach and SPs at the same time. Everything I found so far with Update/Insert/Delete operations was with SQL codes in the body of the program with some question marks in the bodies of statements. Unfortunatel y I couldn't understand those codes.
vovan
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message news:OE***** *********@TK2MS FTNGP03.phx.gbl ... Vovan, > I cannot find a nice sample at the moment, however you need the datarowstat e to get the changed rows per table in a copy of your dataset > Those you update to your database in the sequence childs deleted parents deleted parents added childs added parents updated childs updated > However you use for that the dataadapter and not the executenonquery as I get the idea you want to do. > If everything goes right than you have to do an acceptchanges at the end. > Quickly written in this messages so watch typos or whatever. > Cor > > > > "vovan" <so*****@vovan. comschreef in bericht news:eT**** *********@TK2MS FTNGP06.phx.gbl ... >I'm creating DataSet, then 2 DataTables, then DataRelation between >those DataTables. >I populate DataTables with DataAdapters. Data from each table is >displaye d in Grids. >For display everything works fine - if I change the current record in >the Parent grid then the Child grid displays records related to the >Parent. >In order to update any record in both Parent and Child underlying >datasource s (SQL Server tables) I need to know ID of the record. >What is the proper way to get an ID (it exists in the DataTable, in >BindingSou rce)? I just do not know how to get it? The only way I >found (I don't like it) is to bind ID field to TextBox control and >then when I need ID I get it from the bound TextBox. >> >Thank you >vovan >> >> >> > >
Are you talking about identity columns? You have identity columns in your
parent table, and it is stored in the child table as well? How are you
doing your updates? Are you updating the parent first, and then the child
table? Do you have cascading changes turned on from the parent to the
child?
Robin S.
--------------------
"vovan" <so*****@vovan. comwrote in message
news:eT******** *****@TK2MSFTNG P06.phx.gbl...
I'm creating DataSet, then 2 DataTables, then DataRelation between those
DataTables.
I populate DataTables with DataAdapters. Data from each table is
displayed in Grids.
For display everything works fine - if I change the current record in the
Parent grid then the Child grid displays records related to the Parent.
In order to update any record in both Parent and Child underlying
datasources (SQL Server tables) I need to know ID of the record.
What is the proper way to get an ID (it exists in the DataTable, in
BindingSource)? I just do not know how to get it? The only way I found (I
don't like it) is to bind ID field to TextBox control and then when I
need ID I get it from the bound TextBox.
Thank you
vovan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ken1 |
last post by:
I am going to drop a primary key from one column and create a new
column to be used as primary key in an existing database.
The old column was a date column which someone earlier though was a
good candidate for a primary key which we all know it's not.
Now I want to add a new field, i.e. called ID, with a normal number
sequence as primary key.
I have dropped the primary key, created the new column, created the
new sequence and created...
|
by: Philip Sherman |
last post by:
I'm trying to copy production statistics to a test database and can't
set the column statistics for a VARGRAPHIC column to match what RUNSTATS
generated on production.
The reason code and some testing I did indicates that the length of the
low2key value is too long. It almost looks like the potential length of
data to be stored is being calculated on the length of the hex string;
without consideration that two bytes of the string...
|
by: Brian Brane |
last post by:
I have properties that wrap DataRow columns as in:
public int aNumber
{ get{ return m_DataRow; }
set{ m_DataRow = value; } }
If the column happens to contain DBNull, I get a cast
exception since DBNull cannot be converted to int. I
wrote the following method that looks up the column's
data type and if it is a ValueType, returns the default
value for the ValueType.
|
by: Amber |
last post by:
There are times when you will need to highlight or otherwise modify
the contents of a particular DataGrid row-column value based upon the
value in the column. In this example we will select the CompanyName,
ContactName, and ContactTitle columns from the Customers table in the
Northwind database. Whenever the value of ContactTitle equals "Owner"
we will change the font color to red.
We can do this by using an ItemTemplate where we have...
|
by: |
last post by:
Hello All,
I am having a lot of difficulty trying to bind a templated column, that is
programmatically created for a datagrid, to a datasource column.
I have a datasource containing 2 columns, ID and VALUE.
I would like to create a templated column in the datagrid that is bound to
the VALUE column of the datasource.
| |
by: Owen T. Soroke |
last post by:
Using VB.NET
I have a ListView with several columns.
Two columns contain integer values, while the remaining contain string
values.
I am confused as to how I would provide functionality to sort columns
based on the column header the user has clicked in both Ascending and
Descending formats.
|
by: Bob Day |
last post by:
VS 2003, sql
How do you determine the data type of a column if its value is DBNull?
1)Table:
Column1 STRING non-nullable
2) Fill to a DataSet via DataAdapter
3) dim Data_Type_Is as object
|
by: Peter Gibbs |
last post by:
I need some help with this problem.
I'm using Access 2002 with XP.
My problem is with a 2-column listbox.
My VBA code puts text data into the listbox.
The problem is that the text data ocasionally includes commas (,) and
full-stops (.) - and when the data is placed in a column, Access confuses
the punctuation within the text with delimiters and splits the text across
columns.
|
by: VbaNewbee |
last post by:
I have a form with a few filters. Once the user clicks "search button", the code first evaluates my filters, then shows the query results in a List Box" titled backschedule.
I have a few text boxes below the list box that add sum values in the query columns using Nz() Function.
Example
"openpoqtytotal = openpoqtytotal + Nz(Forms!!backschedule.Column(4, i), 0)"
My Problem , The Nz() Function works fine for summing up all values in the...
|
by: Lou O |
last post by:
Is it possible to use the row (index) of a list box as control source
Property for a text box?
Example: Text1.ControlSource Property is set to "= List1.Column(0,2)"
in design view.
When I open the form, Text1 does not display the value of
List1.Column(0,2)
Am I missing something?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |