473,386 Members | 2,114 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,386 software developers and data experts.

Get column value

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

Apr 15 '07 #1
7 2137
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*************@TK2MSFTNGP06.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

Apr 16 '07 #2
Thank you Cor
First of all, I need to use ExecuteNoneQuery 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**************@TK2MSFTNGP03.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*************@TK2MSFTNGP06.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


Apr 16 '07 #3
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**************@TK2MSFTNGP05.phx.gbl...
Thank you Cor
First of all, I need to use ExecuteNoneQuery 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**************@TK2MSFTNGP03.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*************@TK2MSFTNGP06.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



Apr 16 '07 #4
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****************@TK2MSFTNGP04.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**************@TK2MSFTNGP05.phx.gbl...
>Thank you Cor
First of all, I need to use ExecuteNoneQuery 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**************@TK2MSFTNGP03.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*************@TK2MSFTNGP06.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





Apr 16 '07 #5
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**************@TK2MSFTNGP02.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****************@TK2MSFTNGP04.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**************@TK2MSFTNGP05.phx.gbl...
>>Thank you Cor
First of all, I need to use ExecuteNoneQuery 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**************@TK2MSFTNGP03.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*************@TK2MSFTNGP06.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
>
>
>




Apr 16 '07 #6
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****************@TK2MSFTNGP04.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**************@TK2MSFTNGP02.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****************@TK2MSFTNGP04.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**************@TK2MSFTNGP05.phx.gbl...
Thank you Cor
First of all, I need to use ExecuteNoneQuery 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**************@TK2MSFTNGP03.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*************@TK2MSFTNGP06.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
>>
>>
>>
>
>




Apr 16 '07 #7
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*************@TK2MSFTNGP06.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

Apr 17 '07 #8

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

Similar topics

5
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...
12
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...
4
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...
0
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...
2
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,...
19
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...
3
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...
4
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...
0
VbaNewbee
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
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,...
0
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...

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.