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 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
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
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 >
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |
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...
| |