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

DataTable has now rows in it after fill

P: n/a
I am ruinning this in the global.asa VIA Visual Studio VB .NET (framework 1.1)

I have a access database with a table called tblCounters with a feild called
Counters
with on row of data in it with a number. When I run the following code

Imports System.Data
Imports System.Data.OleDb

Sub Session_Start......
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapter
Dim dbcmd As OleDbCommandBuilder
Dim dbdsn As New Dataset("tblCounters")
Dim dbtab As New DataTable("Counters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Lock()
strcon = "PROVIDER=Microsoft.Jet.4.0; DATA Source=C:\Folder\db1.mdb; User
id=admin;password=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection(strcon)
dbadp = New OleDbDataAdapter(strsql, dbconn)
dbcmd = New OleDbCommandBuilder(dbadp)
dbadp.Fill(dbdsn, "Counters")

At this point I should have filled the dataset dbdsn with a table called
"Counters" with one row of data, right? When I try and run this code

cnt = dbdsn.Rows(0).Item("Counters")

I get an error that my table has no rows.
When I look in the locals window under dbtab, the rows say 0 also?

Any suggestions?

Thanks

May 10 '06 #1
Share this Question
Share on Google+
4 Replies

P: n/a
You are instnating a connection called 'dsconn', but you are using a
connection called 'dbconn', which from the looks of it, never gets
instantiated. I don't know where 'dsconn' is declared, not in the block you
pasted.

Also, there is no way you could say 'dbdsn.Rows...', because a dataset does
not have a Rows property.

I would confirm that you are connection to the database you think you are
connecting to, and that this table does indeed have rows in the database.

"Andre" <An***@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
I am ruinning this in the global.asa VIA Visual Studio VB .NET (framework
1.1)

I have a access database with a table called tblCounters with a feild
called
Counters
with on row of data in it with a number. When I run the following code

Imports System.Data
Imports System.Data.OleDb

Sub Session_Start......
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapter
Dim dbcmd As OleDbCommandBuilder
Dim dbdsn As New Dataset("tblCounters")
Dim dbtab As New DataTable("Counters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Lock()
strcon = "PROVIDER=Microsoft.Jet.4.0; DATA Source=C:\Folder\db1.mdb; User
id=admin;password=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection(strcon)
dbadp = New OleDbDataAdapter(strsql, dbconn)
dbcmd = New OleDbCommandBuilder(dbadp)
dbadp.Fill(dbdsn, "Counters")

At this point I should have filled the dataset dbdsn with a table called
"Counters" with one row of data, right? When I try and run this code

cnt = dbdsn.Rows(0).Item("Counters")

I get an error that my table has no rows.
When I look in the locals window under dbtab, the rows say 0 also?

Any suggestions?

Thanks

May 10 '06 #2

P: n/a
I did not cut and past, I typed this code so
dsconn should be dbconn
Dim dbasp As OleDbDataAdapter should be Dim dbadp As OleDbDataAdapter
cnt = dbtab.Rows(0).Item("Counters")

Do I have to name the table somewhere when I read it?
"Marina Levit [MVP]" wrote:
You are instnating a connection called 'dsconn', but you are using a
connection called 'dbconn', which from the looks of it, never gets
instantiated. I don't know where 'dsconn' is declared, not in the block you
pasted.

Also, there is no way you could say 'dbdsn.Rows...', because a dataset does
not have a Rows property.

I would confirm that you are connection to the database you think you are
connecting to, and that this table does indeed have rows in the database.

"Andre" <An***@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
I am ruinning this in the global.asa VIA Visual Studio VB .NET (framework
1.1)

I have a access database with a table called tblCounters with a feild
called
Counters
with on row of data in it with a number. When I run the following code

Imports System.Data
Imports System.Data.OleDb

Sub Session_Start......
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapter
Dim dbcmd As OleDbCommandBuilder
Dim dbdsn As New Dataset("tblCounters")
Dim dbtab As New DataTable("Counters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Lock()
strcon = "PROVIDER=Microsoft.Jet.4.0; DATA Source=C:\Folder\db1.mdb; User
id=admin;password=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection(strcon)
dbadp = New OleDbDataAdapter(strsql, dbconn)
dbcmd = New OleDbCommandBuilder(dbadp)
dbadp.Fill(dbdsn, "Counters")

At this point I should have filled the dataset dbdsn with a table called
"Counters" with one row of data, right? When I try and run this code

cnt = dbdsn.Rows(0).Item("Counters")

I get an error that my table has no rows.
When I look in the locals window under dbtab, the rows say 0 also?

Any suggestions?

Thanks


May 10 '06 #3

P: n/a
Well, you are filling a dataset called 'dbdsn'. But trying to get data out
of a datatable called 'dbtab'? It's one or the other. Either you fill the
dataset and look in the dataset after for data, or you fill the datatable
and look for your data in the datatable. But you are putting data in one
object, but expecting it to appear in the other?

I think you need to show your actual code, because you have several mistakes
already, and it's hard to help you if we can't even tell what the actual
code is.

"Andre" <An***@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
I did not cut and past, I typed this code so
dsconn should be dbconn
Dim dbasp As OleDbDataAdapter should be Dim dbadp As OleDbDataAdapter
cnt = dbtab.Rows(0).Item("Counters")

Do I have to name the table somewhere when I read it?
"Marina Levit [MVP]" wrote:
You are instnating a connection called 'dsconn', but you are using a
connection called 'dbconn', which from the looks of it, never gets
instantiated. I don't know where 'dsconn' is declared, not in the block
you
pasted.

Also, there is no way you could say 'dbdsn.Rows...', because a dataset
does
not have a Rows property.

I would confirm that you are connection to the database you think you are
connecting to, and that this table does indeed have rows in the database.

"Andre" <An***@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
>I am ruinning this in the global.asa VIA Visual Studio VB .NET
>(framework
>1.1)
>
> I have a access database with a table called tblCounters with a feild
> called
> Counters
> with on row of data in it with a number. When I run the following code
>
> Imports System.Data
> Imports System.Data.OleDb
>
> Sub Session_Start......
> Dim dbconn As OleDbConnection
> Dim dbasp As OleDbDataAdapter
> Dim dbcmd As OleDbCommandBuilder
> Dim dbdsn As New Dataset("tblCounters")
> Dim dbtab As New DataTable("Counters")
> Dim strcon As String
> Dim strsql As String
> Dim count As Double
>
> Application.Lock()
> strcon = "PROVIDER=Microsoft.Jet.4.0; DATA Source=C:\Folder\db1.mdb;
> User
> id=admin;password=;"
> strsql = "Select * From tblCounter"
> dsconn = New OleDbConnection(strcon)
> dbadp = New OleDbDataAdapter(strsql, dbconn)
> dbcmd = New OleDbCommandBuilder(dbadp)
> dbadp.Fill(dbdsn, "Counters")
>
> At this point I should have filled the dataset dbdsn with a table
> called
> "Counters" with one row of data, right? When I try and run this code
>
> cnt = dbdsn.Rows(0).Item("Counters")
>
> I get an error that my table has no rows.
> When I look in the locals window under dbtab, the rows say 0 also?
>
> Any suggestions?
>
> Thanks
>


May 10 '06 #4

P: n/a
found it, I needed to add

dbtab = dbdsn.tables("Counters")

Thanks.

Sometimes you cant see the trees because of the forest!

"Marina Levit [MVP]" wrote:
You are instnating a connection called 'dsconn', but you are using a
connection called 'dbconn', which from the looks of it, never gets
instantiated. I don't know where 'dsconn' is declared, not in the block you
pasted.

Also, there is no way you could say 'dbdsn.Rows...', because a dataset does
not have a Rows property.

I would confirm that you are connection to the database you think you are
connecting to, and that this table does indeed have rows in the database.

"Andre" <An***@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
I am ruinning this in the global.asa VIA Visual Studio VB .NET (framework
1.1)

I have a access database with a table called tblCounters with a feild
called
Counters
with on row of data in it with a number. When I run the following code

Imports System.Data
Imports System.Data.OleDb

Sub Session_Start......
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapter
Dim dbcmd As OleDbCommandBuilder
Dim dbdsn As New Dataset("tblCounters")
Dim dbtab As New DataTable("Counters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Lock()
strcon = "PROVIDER=Microsoft.Jet.4.0; DATA Source=C:\Folder\db1.mdb; User
id=admin;password=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection(strcon)
dbadp = New OleDbDataAdapter(strsql, dbconn)
dbcmd = New OleDbCommandBuilder(dbadp)
dbadp.Fill(dbdsn, "Counters")

At this point I should have filled the dataset dbdsn with a table called
"Counters" with one row of data, right? When I try and run this code

cnt = dbdsn.Rows(0).Item("Counters")

I get an error that my table has no rows.
When I look in the locals window under dbtab, the rows say 0 also?

Any suggestions?

Thanks


May 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.