EDN Admin
Well-known member
Dear reader,
I have a simple problem....
- I make a connection to a database and read a certain table and fills a datagridview with it.
- This datagridview is on a different form
- Some labels are on this form too and before i present the form i want to retrieve data from the datagridview and place it into labels.... see underlined bold code
The problem is, it doesnt retrieve the data..... it delivers a zero of wich i am sure it contains a big number....
Do you see where i make a mistake in my thinking....
Greetings
Joska Make a new datatable
Dim dt As New DataTable()
Make the connection to the database
Dim conBoogieDatabase As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strBoogiePadFile & ";Persist Security Info=False;User Id=admin;Password=;")
conBoogieDatabase.Open()
Using cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conBoogieDatabase
cmd.CommandText = "select * from Projectgegevens"
Dim rdr As System.Data.OleDb.OleDbDataReader = cmd.ExecuteReader()
dt.Load(rdr)
End Using
conBoogieDatabase.Close()
frmBoogie.DataGridViewBoogieProjectgegevens.DataSource = dt
frmBoogie.DataGridViewBoogieProjectgegevens.AutoResizeColumns()
frmBoogie.lblHuidig.Text = "Huidig=" & frmBoogie.DataGridViewBoogieProjectgegevens.Rows(1).Cells(12).Value
frmBoogie.lblToekomstig.Text = "Toekomstig=" & frmBoogie.DataGridViewBoogieProjectgegevens.Rows(1).Cells(13).Value
frmBoogie.ShowDialog(Me)
View the full article
I have a simple problem....
- I make a connection to a database and read a certain table and fills a datagridview with it.
- This datagridview is on a different form
- Some labels are on this form too and before i present the form i want to retrieve data from the datagridview and place it into labels.... see underlined bold code
The problem is, it doesnt retrieve the data..... it delivers a zero of wich i am sure it contains a big number....
Do you see where i make a mistake in my thinking....
Greetings
Joska Make a new datatable
Dim dt As New DataTable()
Make the connection to the database
Dim conBoogieDatabase As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strBoogiePadFile & ";Persist Security Info=False;User Id=admin;Password=;")
conBoogieDatabase.Open()
Using cmd As New System.Data.OleDb.OleDbCommand()
cmd.Connection = conBoogieDatabase
cmd.CommandText = "select * from Projectgegevens"
Dim rdr As System.Data.OleDb.OleDbDataReader = cmd.ExecuteReader()
dt.Load(rdr)
End Using
conBoogieDatabase.Close()
frmBoogie.DataGridViewBoogieProjectgegevens.DataSource = dt
frmBoogie.DataGridViewBoogieProjectgegevens.AutoResizeColumns()
frmBoogie.lblHuidig.Text = "Huidig=" & frmBoogie.DataGridViewBoogieProjectgegevens.Rows(1).Cells(12).Value
frmBoogie.lblToekomstig.Text = "Toekomstig=" & frmBoogie.DataGridViewBoogieProjectgegevens.Rows(1).Cells(13).Value
frmBoogie.ShowDialog(Me)
View the full article