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

Datagrid issue

Hello,

I developing some code that will select a few value and together they will
be presented in a table (datagrid). But i have the following
issues/question:

1. How can i add just one row to a grid (header and previous added row
should stay)?

2. I have 4 string and 1 numeric variables that i want to put together as
one row into the table, how can i handle them (they are not part of a
database.

3. How can i count a collumn inside this datagrid ???

Below you see a part of my code.

thanks
--
Edward van Nijmweegen
Dim dsFinal As New DataSet
Dim daFinal As OleDbDataAdapter
Dim conn As OleDbConnection
Dim strConn As String
Dim strSQLFinal As String
strConn = "Provider = microsoft.jet.OLEDB.4.0;"
strConn &= "Data Source = c:\Pricelist\pricelist.mdb;"
strSQLFinal = "SELECT fldID, fldArtikelnummer, "
strSQLFinal = strSQLFinal + " fldOmschrijving, fldPrice, "
strSQLFinal = strSQLFinal + " fldCode, fldLanguage, "
strSQLFinal = strSQLFinal + " fldLicensecount, fldBusinessunit, "
strSQLFinal = strSQLFinal + " fldLevel, fldProductfamily, "
strSQLFinal = strSQLFinal + " fldVolumelevel, fldPool, fldItem "
strSQLFinal = strSQLFinal + " FROM tblPriceList"
strSQLFinal = strSQLFinal + " WHERE fldID = " & cboProduct.SelectedIndex
conn = New OleDbConnection(strConn)
conn.Open()

daFinal = New OleDbDataAdapter(strSQLFinal, conn)
daFinal.Fill(dsFinal)
....
....
<All kind of calculations>
....
....

DataGrid1.DataSource = dsFinal.Tables("tblPriceList")
DataGrid1.DataMember = "tblPriceList"
....
....
<My issue>

.....
.....

conn3.Close()
conn3 = Nothing
Nov 21 '05 #1
4 1091
Edward,

The datagrid is not a table, it is a grid that shows the data, when it is
used in combination with a dataadapter as in your case, than that is in a
datatable.

Between that can even be the dataview, which as well only handles the
references to the datatable.

Which means that you can only show information when you add the information
in the underlaying datasource (the datatable in your case)

For that you can use a currencymanager.add, a dataview.add or directly what
it is in your case a datatable.add of a datarow.

By the way how you build your SQL string is against everything what is
forever told in this newsgroup. You use concatination and in that the +. I
do not see the need for the first and in the second it is errorfull. In
VBNet is for the last the &.

To proceed in VBNet a commandline on the next line you can use & _

I hope this helps?

Cor
"Edward van Nijmweegen"
Hello,

I developing some code that will select a few value and together they will
be presented in a table (datagrid). But i have the following
issues/question:

1. How can i add just one row to a grid (header and previous added row
should stay)?

2. I have 4 string and 1 numeric variables that i want to put together as
one row into the table, how can i handle them (they are not part of a
database.

3. How can i count a collumn inside this datagrid ???

Below you see a part of my code.

thanks
--
Edward van Nijmweegen
Dim dsFinal As New DataSet
Dim daFinal As OleDbDataAdapter
Dim conn As OleDbConnection
Dim strConn As String
Dim strSQLFinal As String
strConn = "Provider = microsoft.jet.OLEDB.4.0;"
strConn &= "Data Source = c:\Pricelist\pricelist.mdb;"
strSQLFinal = "SELECT fldID, fldArtikelnummer, "
strSQLFinal = strSQLFinal + " fldOmschrijving, fldPrice, "
strSQLFinal = strSQLFinal + " fldCode, fldLanguage, "
strSQLFinal = strSQLFinal + " fldLicensecount, fldBusinessunit, "
strSQLFinal = strSQLFinal + " fldLevel, fldProductfamily, "
strSQLFinal = strSQLFinal + " fldVolumelevel, fldPool, fldItem "
strSQLFinal = strSQLFinal + " FROM tblPriceList"
strSQLFinal = strSQLFinal + " WHERE fldID = " & cboProduct.SelectedIndex
conn = New OleDbConnection(strConn)
conn.Open()

daFinal = New OleDbDataAdapter(strSQLFinal, conn)
daFinal.Fill(dsFinal)
...
...
<All kind of calculations>
...
...

DataGrid1.DataSource = dsFinal.Tables("tblPriceList")
DataGrid1.DataMember = "tblPriceList"
...
...
<My issue>

....
....

conn3.Close()
conn3 = Nothing

Nov 21 '05 #2
Thanks Cor,

I'm new in VB.NET so........

But i realized this morning that a database is not the source of the grid,
but the calculations. After i select some values on the form, the query is
build up and should result with only one line. The values of the fields out
of this results will be used to do caluculations like db.price * frm.qty =
total, etc.... price comes out the database, qty is filled in on the form
and total is the result. These 3 fields should be presented in the grid
together with some other fields out of the database.

So i assume that the database should not be the datasource of the grid, am
i right ?

thanks a lot.

Regards,

--
Edward van Nijmweegen

Op Wed, 10 Nov 2004 11:01:09 +0100 schreef Cor Ligthert:
Edward,

The datagrid is not a table, it is a grid that shows the data, when it is
used in combination with a dataadapter as in your case, than that is in a
datatable.

Between that can even be the dataview, which as well only handles the
references to the datatable.

Which means that you can only show information when you add the information in the underlaying datasource (the datatable in your case)

For that you can use a currencymanager.add, a dataview.add or directly what it is in your case a datatable.add of a datarow.

By the way how you build your SQL string is against everything what is
forever told in this newsgroup. You use concatination and in that the +. I do not see the need for the first and in the second it is errorfull. In
VBNet is for the last the &.

To proceed in VBNet a commandline on the next line you can use & _

I hope this helps?

Cor
"Edward van Nijmweegen"
Hello,

I developing some code that will select a few value and together they will be presented in a table (datagrid). But i have the following
issues/question:

1. How can i add just one row to a grid (header and previous added row
should stay)?

2. I have 4 string and 1 numeric variables that i want to put together as one row into the table, how can i handle them (they are not part of a
database.

3. How can i count a collumn inside this datagrid ???

Below you see a part of my code.

thanks
--
Edward van Nijmweegen
Dim dsFinal As New DataSet
Dim daFinal As OleDbDataAdapter
Dim conn As OleDbConnection
Dim strConn As String
Dim strSQLFinal As String
strConn = "Provider = microsoft.jet.OLEDB.4.0;"
strConn &= "Data Source = c:\Pricelist\pricelist.mdb;"
strSQLFinal = "SELECT fldID, fldArtikelnummer, "
strSQLFinal = strSQLFinal + " fldOmschrijving, fldPrice, "
strSQLFinal = strSQLFinal + " fldCode, fldLanguage, "
strSQLFinal = strSQLFinal + " fldLicensecount, fldBusinessunit, "
strSQLFinal = strSQLFinal + " fldLevel, fldProductfamily, "
strSQLFinal = strSQLFinal + " fldVolumelevel, fldPool, fldItem "
strSQLFinal = strSQLFinal + " FROM tblPriceList"
strSQLFinal = strSQLFinal + " WHERE fldID = " & cboProduct.SelectedIndex
conn = New OleDbConnection(strConn)
conn.Open()

daFinal = New OleDbDataAdapter(strSQLFinal, conn)
daFinal.Fill(dsFinal)
...
...
<All kind of calculations>
...
...

DataGrid1.DataSource = dsFinal.Tables("tblPriceList")
DataGrid1.DataMember = "tblPriceList"
...
...
<My issue>

....
....

conn3.Close()
conn3 = Nothing

Nov 21 '05 #3
Edward,

The datatable is the datasource (in your situation). You can add as much
columns to the datatable as you want (which will be showed when you do not
use styles or can be showed using that). And in that datatable.column.add
you can set expressions.

http://msdn.microsoft.com/library/de...ssaddtopic.asp

You can as well add rows which holds calculations, you get than the idea of
a spreadsheet, however I would not do that in that way when you have to
upgrade afterwards.

http://msdn.microsoft.com/library/de...mputetopic.asp

Only the columns in your select will be updated in the datatabase by the way
when you do not build your own command updates (with what when you are a
newbie I would wait a while)

I hope this helps?

Cor
Thanks Cor,

I'm new in VB.NET so........

But i realized this morning that a database is not the source of the grid,
but the calculations. After i select some values on the form, the query is
build up and should result with only one line. The values of the fields
out
of this results will be used to do caluculations like db.price * frm.qty =
total, etc.... price comes out the database, qty is filled in on the form
and total is the result. These 3 fields should be presented in the grid
together with some other fields out of the database.

So i assume that the database should not be the datasource of the grid, am
i right ?

thanks a lot.

Regards,

--
Edward van Nijmweegen

Op Wed, 10 Nov 2004 11:01:09 +0100 schreef Cor Ligthert:
Edward,

The datagrid is not a table, it is a grid that shows the data, when it is
used in combination with a dataadapter as in your case, than that is in a
datatable.

Between that can even be the dataview, which as well only handles the
references to the datatable.

Which means that you can only show information when you add the

information
in the underlaying datasource (the datatable in your case)

For that you can use a currencymanager.add, a dataview.add or directly

what
it is in your case a datatable.add of a datarow.

By the way how you build your SQL string is against everything what is
forever told in this newsgroup. You use concatination and in that the +.

I
do not see the need for the first and in the second it is errorfull. In
VBNet is for the last the &.

To proceed in VBNet a commandline on the next line you can use & _

I hope this helps?

Cor
"Edward van Nijmweegen"
Hello,

I developing some code that will select a few value and together they will be presented in a table (datagrid). But i have the following
issues/question:

1. How can i add just one row to a grid (header and previous added row
should stay)?

2. I have 4 string and 1 numeric variables that i want to put together as one row into the table, how can i handle them (they are not part of a
database.

3. How can i count a collumn inside this datagrid ???

Below you see a part of my code.

thanks
--
Edward van Nijmweegen
Dim dsFinal As New DataSet
Dim daFinal As OleDbDataAdapter
Dim conn As OleDbConnection
Dim strConn As String
Dim strSQLFinal As String
strConn = "Provider = microsoft.jet.OLEDB.4.0;"
strConn &= "Data Source = c:\Pricelist\pricelist.mdb;"
strSQLFinal = "SELECT fldID, fldArtikelnummer, "
strSQLFinal = strSQLFinal + " fldOmschrijving, fldPrice, "
strSQLFinal = strSQLFinal + " fldCode, fldLanguage, "
strSQLFinal = strSQLFinal + " fldLicensecount, fldBusinessunit, "
strSQLFinal = strSQLFinal + " fldLevel, fldProductfamily, "
strSQLFinal = strSQLFinal + " fldVolumelevel, fldPool, fldItem "
strSQLFinal = strSQLFinal + " FROM tblPriceList"
strSQLFinal = strSQLFinal + " WHERE fldID = " & cboProduct.SelectedIndex
conn = New OleDbConnection(strConn)
conn.Open()

daFinal = New OleDbDataAdapter(strSQLFinal, conn)
daFinal.Fill(dsFinal)
...
...
<All kind of calculations>
...
...

DataGrid1.DataSource = dsFinal.Tables("tblPriceList")
DataGrid1.DataMember = "tblPriceList"
...
...
<My issue>

....
....

conn3.Close()
conn3 = Nothing

Nov 21 '05 #4
Edward,

I see I forgot the most direct answer on your question, the datatable in a
dataset is a disconnected datasource, this in oposite with a recordset which
is a connected datasource.

I hope this helps?

Cor

"Edward van Nijmweegen"
..
Thanks Cor,

I'm new in VB.NET so........

But i realized this morning that a database is not the source of the grid,
but the calculations. After i select some values on the form, the query is
build up and should result with only one line. The values of the fields
out
of this results will be used to do caluculations like db.price * frm.qty =
total, etc.... price comes out the database, qty is filled in on the form
and total is the result. These 3 fields should be presented in the grid
together with some other fields out of the database.

So i assume that the database should not be the datasource of the grid, am
i right ?

thanks a lot.

Regards,

--
Edward van Nijmweegen

Op Wed, 10 Nov 2004 11:01:09 +0100 schreef Cor Ligthert:
Edward,

The datagrid is not a table, it is a grid that shows the data, when it is
used in combination with a dataadapter as in your case, than that is in a
datatable.

Between that can even be the dataview, which as well only handles the
references to the datatable.

Which means that you can only show information when you add the

information
in the underlaying datasource (the datatable in your case)

For that you can use a currencymanager.add, a dataview.add or directly

what
it is in your case a datatable.add of a datarow.

By the way how you build your SQL string is against everything what is
forever told in this newsgroup. You use concatination and in that the +.

I
do not see the need for the first and in the second it is errorfull. In
VBNet is for the last the &.

To proceed in VBNet a commandline on the next line you can use & _

I hope this helps?

Cor
"Edward van Nijmweegen"
Hello,

I developing some code that will select a few value and together they will be presented in a table (datagrid). But i have the following
issues/question:

1. How can i add just one row to a grid (header and previous added row
should stay)?

2. I have 4 string and 1 numeric variables that i want to put together as one row into the table, how can i handle them (they are not part of a
database.

3. How can i count a collumn inside this datagrid ???

Below you see a part of my code.

thanks
--
Edward van Nijmweegen
Dim dsFinal As New DataSet
Dim daFinal As OleDbDataAdapter
Dim conn As OleDbConnection
Dim strConn As String
Dim strSQLFinal As String
strConn = "Provider = microsoft.jet.OLEDB.4.0;"
strConn &= "Data Source = c:\Pricelist\pricelist.mdb;"
strSQLFinal = "SELECT fldID, fldArtikelnummer, "
strSQLFinal = strSQLFinal + " fldOmschrijving, fldPrice, "
strSQLFinal = strSQLFinal + " fldCode, fldLanguage, "
strSQLFinal = strSQLFinal + " fldLicensecount, fldBusinessunit, "
strSQLFinal = strSQLFinal + " fldLevel, fldProductfamily, "
strSQLFinal = strSQLFinal + " fldVolumelevel, fldPool, fldItem "
strSQLFinal = strSQLFinal + " FROM tblPriceList"
strSQLFinal = strSQLFinal + " WHERE fldID = " & cboProduct.SelectedIndex
conn = New OleDbConnection(strConn)
conn.Open()

daFinal = New OleDbDataAdapter(strSQLFinal, conn)
daFinal.Fill(dsFinal)
...
...
<All kind of calculations>
...
...

DataGrid1.DataSource = dsFinal.Tables("tblPriceList")
DataGrid1.DataMember = "tblPriceList"
...
...
<My issue>

....
....

conn3.Close()
conn3 = Nothing

Nov 21 '05 #5

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

Similar topics

11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
2
by: Dimitris Pantazopoulos | last post by:
Hello. I am trying to do the simplest of things. These are exactly the steps I follow: 1. create an sqlConnection to an SQL Server database. 2. create a DataSource and produce a DataSet to a...
4
by: jibran | last post by:
Hello. I have wrapped the DataGrid control with my own class (SmartDataGrid) adding some necessary functionality. My current webform has 2 SmartDataGrids. The first is populated by selected...
3
by: Tim McKinney | last post by:
I have a read-only datagrid that I use to display a heirarchal model of three tables (The example I am setting up uses the Customer, Orders, and Order Detail tables from the northwind database). I...
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
7
by: Earl | last post by:
Any known fixes for the wacky right-alignment bug in the WinForms datagrid (VS2003)? I've tried Ken's workaround...
3
by: Brian Tkatch | last post by:
I have a form with two DataGrids, which are kept in sync manually via Stored PROCEDURE calls. That is, when a record is selected on the first grid, a stored PROCEDURE is CALLed to Fill() the next...
0
by: Newish | last post by:
Hi Couple of questions on datagrid 1) Is there a performance issue when using datagrid to display data from a datatable. 2) Is there a security issue when using datagrid to display data...
8
by: =?Utf-8?B?bWlrZWc=?= | last post by:
Hi, I am building a small Help Desk application for my company and need to be able to edit "open" help desk issues. I use a simple datagrid to display each issue (6 per page) , with an Edit...
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...
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...
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...
0
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,...
0
tracyyun
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...

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.