By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Datagrid issue

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.