473,491 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataTable has now rows in it after fill

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
4 3191
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
2195
by: Eva | last post by:
Hi i am trying to insert a new row into one of my datatabels that i have in my dataset when a button is clicked. here is my code Dim ClientInsRow As DataRow = dtClient.NewRo ...
5
2229
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
8
1583
by: Stephen | last post by:
I am trying to add some code to below to include a datatable and fill the datatable. The reason for doing this is so as I can check to see whether there are any rows returned by the stored...
4
1512
by: Stephen | last post by:
I am trying to add some code to below to include a datatable and fill the datatable. The reason for doing this is so as I can check to see whether there are any rows returned by the stored...
1
19738
by: Lars E | last post by:
Hi all I have a small problem. I have a datatable with 8 columns. But it is only data in 5 of the columns. Data for the remaing 3 columns is in another dataset. I Want to run trough the...
10
6498
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
1
5705
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the...
9
3990
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
2
2960
by: Ryan Liu | last post by:
Hi, If I have a very big view in database, it covers 15 tables, each table has 1000 columns. When I issue select * from view, the database will give error -- too many columns. Can I use a...
0
7115
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
6978
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
7154
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
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7360
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...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.