473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

vb 2005 express > querry table in access and put contents into array

Hi all,

I've got some general VB experience, but i'm not sure how to approach
the problem at hand. here is what i've got:

I have a database that holds employee data (access database). I want
to make vb 2005 express look in a table (called 'EmpData') and extract
the phone login ID's for all of the agents in the table who are still
employed or who have not left the company yet (but may have a future
end date). i want to store each of those phone logins in an array,
which is used by another procedure to extract phone usage statistics.

so the SQL statement would look like this:

(SELECT EmpData.PhoneLogin FROM EmpData WHERE (((EmpData.EndDate) Is
Null Or (EmpData.EndDate)>Now()));)

i just don't know how to make VB execute this statement and store the
results in an array??? also, will i need a 1 dimensional or 2
dimensional array for this (since i want to store 'PhoneLogin', but i'm
using 'EndDate' to get the desired results)?

Any help is greatly appreciated.

TIA

AR

Aug 15 '06 #1
2 1960
adm
Rather than store the results in an array, you want to use a datareader
or store them in a data table within a dataset, then loop through the
rows in the data table to do whatever you were planning to do with that
array.

For more info on the data reader technique, see:
http://visualbasic.about.com/od/usin.../aa050303c.htm

Basically, you need to set up an OleDbAdapter to connect to the Access
database, and then go from there. Slightly adapting the code from the
link above:

Dim strConn As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" _
& "User ID=Admin;" _
& "{path}\"employees.mdb"
Dim ocmd As OleDbCommand
Dim odtr As OleDbDataReader

ocmd = New OleDbCommand()
With ocmd
.Connection = New _
OleDbConnection(stConn)
.Connection.Open()
.CommandText = "Select * From Employees"
odtr = .ExecuteReader()
End With


ducky801 wrote:
Hi all,

I've got some general VB experience, but i'm not sure how to approach
the problem at hand. here is what i've got:

I have a database that holds employee data (access database). I want
to make vb 2005 express look in a table (called 'EmpData') and extract
the phone login ID's for all of the agents in the table who are still
employed or who have not left the company yet (but may have a future
end date). i want to store each of those phone logins in an array,
which is used by another procedure to extract phone usage statistics.

so the SQL statement would look like this:

(SELECT EmpData.PhoneLogin FROM EmpData WHERE (((EmpData.EndDate) Is
Null Or (EmpData.EndDate)>Now()));)

i just don't know how to make VB execute this statement and store the
results in an array??? also, will i need a 1 dimensional or 2
dimensional array for this (since i want to store 'PhoneLogin', but i'm
using 'EndDate' to get the desired results)?

Any help is greatly appreciated.

TIA

AR
Aug 15 '06 #2
Ducky,

Why do you not try this.

http://www.vb-tips.com/dbpages.aspx?...2-b1ed16424252

It gives you back also a datatable, the first telephone number is than

datatable.rows(0)(0).ToString

Cor

"ducky801" <ar*******@gmail.comschreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi all,

I've got some general VB experience, but i'm not sure how to approach
the problem at hand. here is what i've got:

I have a database that holds employee data (access database). I want
to make vb 2005 express look in a table (called 'EmpData') and extract
the phone login ID's for all of the agents in the table who are still
employed or who have not left the company yet (but may have a future
end date). i want to store each of those phone logins in an array,
which is used by another procedure to extract phone usage statistics.

so the SQL statement would look like this:

(SELECT EmpData.PhoneLogin FROM EmpData WHERE (((EmpData.EndDate) Is
Null Or (EmpData.EndDate)>Now()));)

i just don't know how to make VB execute this statement and store the
results in an array??? also, will i need a 1 dimensional or 2
dimensional array for this (since i want to store 'PhoneLogin', but i'm
using 'EndDate' to get the desired results)?

Any help is greatly appreciated.

TIA

AR

Aug 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Kincl | last post by:
Hello, I have an array of data in PHP. I would like to insert each member of the array into it's own row in SQL. The array is of variable length, so it would have to be dynamic code. How would...
2
by: Belee | last post by:
1. I am using sql server express and visual studio 2003. I have been able to create the connection to the database in server explorer but cannot update table definitions. It gives an error that...
10
by: Bonj | last post by:
Hi I installed .NET 2005 express edition, and am about to unnistall it again because it can't seem to be able to even insert a resource file into a project. Can anyone tell me is this right?...
9
by: Neil | last post by:
We have an Access 2000 MDB with a SQL 7 back end. We are upgrading SQL Server to SQL 2005, and are considering upgrading to Access 2003. Someone mentioned that they had heard about some...
2
by: Rob Pollard | last post by:
Hi All, I'm pretty new to using these technologies so bear with me. I have created a c# app which communicates with sql-server express 2005. When I run an insert on a table via the SqlCommand...
9
by: =?Utf-8?B?QmVu?= | last post by:
Hi, I'm trying to figure out the purpose of these operators. Now, I know what they do. They shift bits either left or right. But I don't know why would anybody want to do that. I've never seen...
1
by: cnixuser | last post by:
Hello, I am having a problem that I believe is related to the way a stream reader object looks for a text file by default. What I am doing is using a StreamReader object to read the text of a text...
1
by: JA | last post by:
I am moving my site to a host that has SQL Server 2005. I am pretty good with Access, but I don't know much about SQL Server. I'm currently using SQL Server 2000, and I access it with Access...
5
by: matt | last post by:
This is a strange one but I've been stuck on it for days. Any help appreciated. THE PLAN: I've a database that I use a script to grab all the entries for a particular field. I then want to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.