473,785 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ 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.Ole Db

Sub Session_Start.. ....
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapte r
Dim dbcmd As OleDbCommandBui lder
Dim dbdsn As New Dataset("tblCou nters")
Dim dbtab As New DataTable("Coun ters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Loc k()
strcon = "PROVIDER=Micro soft.Jet.4.0; DATA Source=C:\Folde r\db1.mdb; User
id=admin;passwo rd=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection (strcon)
dbadp = New OleDbDataAdapte r(strsql, dbconn)
dbcmd = New OleDbCommandBui lder(dbadp)
dbadp.Fill(dbds n, "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).I tem("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 3215
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***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.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.Ole Db

Sub Session_Start.. ....
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapte r
Dim dbcmd As OleDbCommandBui lder
Dim dbdsn As New Dataset("tblCou nters")
Dim dbtab As New DataTable("Coun ters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Loc k()
strcon = "PROVIDER=Micro soft.Jet.4.0; DATA Source=C:\Folde r\db1.mdb; User
id=admin;passwo rd=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection (strcon)
dbadp = New OleDbDataAdapte r(strsql, dbconn)
dbcmd = New OleDbCommandBui lder(dbadp)
dbadp.Fill(dbds n, "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).I tem("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 OleDbDataAdapte r should be Dim dbadp As OleDbDataAdapte r
cnt = dbtab.Rows(0).I tem("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***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.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.Ole Db

Sub Session_Start.. ....
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapte r
Dim dbcmd As OleDbCommandBui lder
Dim dbdsn As New Dataset("tblCou nters")
Dim dbtab As New DataTable("Coun ters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Loc k()
strcon = "PROVIDER=Micro soft.Jet.4.0; DATA Source=C:\Folde r\db1.mdb; User
id=admin;passwo rd=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection (strcon)
dbadp = New OleDbDataAdapte r(strsql, dbconn)
dbcmd = New OleDbCommandBui lder(dbadp)
dbadp.Fill(dbds n, "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).I tem("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***@discussi ons.microsoft.c om> wrote in message
news:85******** *************** ***********@mic rosoft.com...
I did not cut and past, I typed this code so
dsconn should be dbconn
Dim dbasp As OleDbDataAdapte r should be Dim dbadp As OleDbDataAdapte r
cnt = dbtab.Rows(0).I tem("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***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.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.Ole Db
>
> Sub Session_Start.. ....
> Dim dbconn As OleDbConnection
> Dim dbasp As OleDbDataAdapte r
> Dim dbcmd As OleDbCommandBui lder
> Dim dbdsn As New Dataset("tblCou nters")
> Dim dbtab As New DataTable("Coun ters")
> Dim strcon As String
> Dim strsql As String
> Dim count As Double
>
> Application.Loc k()
> strcon = "PROVIDER=Micro soft.Jet.4.0; DATA Source=C:\Folde r\db1.mdb;
> User
> id=admin;passwo rd=;"
> strsql = "Select * From tblCounter"
> dsconn = New OleDbConnection (strcon)
> dbadp = New OleDbDataAdapte r(strsql, dbconn)
> dbcmd = New OleDbCommandBui lder(dbadp)
> dbadp.Fill(dbds n, "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).I tem("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("C ounters")

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***@discussi ons.microsoft.c om> wrote in message
news:5A******** *************** ***********@mic rosoft.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.Ole Db

Sub Session_Start.. ....
Dim dbconn As OleDbConnection
Dim dbasp As OleDbDataAdapte r
Dim dbcmd As OleDbCommandBui lder
Dim dbdsn As New Dataset("tblCou nters")
Dim dbtab As New DataTable("Coun ters")
Dim strcon As String
Dim strsql As String
Dim count As Double

Application.Loc k()
strcon = "PROVIDER=Micro soft.Jet.4.0; DATA Source=C:\Folde r\db1.mdb; User
id=admin;passwo rd=;"
strsql = "Select * From tblCounter"
dsconn = New OleDbConnection (strcon)
dbadp = New OleDbDataAdapte r(strsql, dbconn)
dbcmd = New OleDbCommandBui lder(dbadp)
dbadp.Fill(dbds n, "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).I tem("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
2240
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 ClientInsRow("Surname") = txtSurname.Tex ClientInsRow("Forename") = txtForename.Tex ClientInsRow("OrgName") = txtOrganisation.Tex ClientInsRow("Address") = txtAddress.Tex
5
2256
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 DataTable first and I then want to roll through the DataTable while in memory checking for errors and then commit the rows to my database table (btw this is in ASP.NET). Is it possible to have data in a datable before attaching at DataAdapter? I'm a...
8
1613
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 procedure. If there are no records returned then this would give me an indicator and I can re-direct the page somewhere more appropriate. Well this is the theory. I have never used datatables before and am not sure how to implemenet what I want so I was...
4
1527
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 procedure. If there are no records returned then this would give me an indicator and I can re-direct the page somewhere more appropriate. Well this is the theory. I have never used datatables before and am not sure how to implemenet what I want so I was...
1
19793
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 datatable and fill out the remaining data. My code so far: if (this.fetch("custinfo", "fetchCustInfo", out customers, parameters))
10
6543
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 have one querie that grabs all of the id's I need for the other 4 queries, but I am not sure how to get them into a DataTable or DataSet, or if that is the best way to do this. Seperately the queries all work with no problems.
1
5737
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 work manually. I am looking for an automated way. Thank you, Max
9
4026
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 DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
2
2982
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 DataAdapter fill DataTable couple times? For example, I only read 5000 columns from the view each time and I read 3 times. It has an id
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.