473,394 Members | 1,739 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,394 software developers and data experts.

Help with Access Database and tables

Hi all,

I am trying to convert to vb.net from VB6 and I am haveing a major problem
with connecting to an Access database and adding, updating, deleting data.

This is what I usually use in vb6:

sqlText As String
dbConn As New ADODB.Connection
rsConn As ADODB.Recordset

dbConn.Provider = "Microsoft.Jet.OLEDB.4.0"
dbConn.Properties("Data Source") = App.Path & "\mydatabase.mdb"
dbConn.Open

sqlText = "SELECT * FROM publishers WHERE series=1"

Set rsConn = New ADODB.Recordset
rsConn.Open sqlText
And to read :

while not rsconn.eof
text1=rsconn("field1")
rsconn.movenext
wend
I do not use SQL, since the database is local to the app and since I do not
have SQL.

So please, any assistance/guidance/etc would be greatly appreciated.

George
Mar 22 '06 #1
2 1354
Here's a simple data access class you can download that demonstrates how to
access SQL Server databases and/or Access databases.
(www.dxonline.com/files/clsData.vb)

This can be adapted to other databases, assuming the proper drivers and
references are present.

Here's an example of how to get a dataset, make changes to it, and update it
back to the database:
Dim dsList As DataSet = clsData.LoadDataSet("Select * from Customers Where
CustID = 100", gsDriver, gsLocation, sDatabase)

If dsList.Tables(0).Rows.Count <> 0 Then
dsList.Tables(0).Row(0).Item("CustType") = "NOP"
clsData.UpdateDataSet(dsList, "Select * from Customers Where CustID =
100", gsDriver, gsLocation, gsDatabase)
End If

Changing gsDriver between "SQL" and "ACCESS" tells the class what kind of
database to use.
gsLocation is either the path to the Access database, or it's the server
name for the SQL Server.
gsDatabase is the name of the Access database file, or the name of the SQL
database.
--
------------------------------------------------------------------------
George Shubin Custom Software Development
dX Software Systems Database Applications
Ph: 503-981-6806 Fax: 503-982-0120
www.dxonline.com ge****@dxonline.com
------------------------------------------------------------------------

"In politics an absurdity is not a handicap." -- Napoleon Bonaparte

"George" <Ge****@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
Hi all,

I am trying to convert to vb.net from VB6 and I am haveing a major problem
with connecting to an Access database and adding, updating, deleting data.

This is what I usually use in vb6:

sqlText As String
dbConn As New ADODB.Connection
rsConn As ADODB.Recordset

dbConn.Provider = "Microsoft.Jet.OLEDB.4.0"
dbConn.Properties("Data Source") = App.Path & "\mydatabase.mdb"
dbConn.Open

sqlText = "SELECT * FROM publishers WHERE series=1"

Set rsConn = New ADODB.Recordset
rsConn.Open sqlText
And to read :

while not rsconn.eof
text1=rsconn("field1")
rsconn.movenext
wend
I do not use SQL, since the database is local to the app and since I do
not
have SQL.

So please, any assistance/guidance/etc would be greatly appreciated.

George

Mar 22 '06 #2
George,

I appreciate your help, but when I went to get the class file, I got an error.

I would like to see it if possible.

Thanks,

George

"George Shubin" wrote:
Here's a simple data access class you can download that demonstrates how to
access SQL Server databases and/or Access databases.
(www.dxonline.com/files/clsData.vb)

This can be adapted to other databases, assuming the proper drivers and
references are present.

Here's an example of how to get a dataset, make changes to it, and update it
back to the database:
Dim dsList As DataSet = clsData.LoadDataSet("Select * from Customers Where
CustID = 100", gsDriver, gsLocation, sDatabase)

If dsList.Tables(0).Rows.Count <> 0 Then
dsList.Tables(0).Row(0).Item("CustType") = "NOP"
clsData.UpdateDataSet(dsList, "Select * from Customers Where CustID =
100", gsDriver, gsLocation, gsDatabase)
End If

Changing gsDriver between "SQL" and "ACCESS" tells the class what kind of
database to use.
gsLocation is either the path to the Access database, or it's the server
name for the SQL Server.
gsDatabase is the name of the Access database file, or the name of the SQL
database.
--
------------------------------------------------------------------------
George Shubin Custom Software Development
dX Software Systems Database Applications
Ph: 503-981-6806 Fax: 503-982-0120
www.dxonline.com ge****@dxonline.com
------------------------------------------------------------------------

"In politics an absurdity is not a handicap." -- Napoleon Bonaparte

"George" <Ge****@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
Hi all,

I am trying to convert to vb.net from VB6 and I am haveing a major problem
with connecting to an Access database and adding, updating, deleting data.

This is what I usually use in vb6:

sqlText As String
dbConn As New ADODB.Connection
rsConn As ADODB.Recordset

dbConn.Provider = "Microsoft.Jet.OLEDB.4.0"
dbConn.Properties("Data Source") = App.Path & "\mydatabase.mdb"
dbConn.Open

sqlText = "SELECT * FROM publishers WHERE series=1"

Set rsConn = New ADODB.Recordset
rsConn.Open sqlText
And to read :

while not rsconn.eof
text1=rsconn("field1")
rsconn.movenext
wend
I do not use SQL, since the database is local to the app and since I do
not
have SQL.

So please, any assistance/guidance/etc would be greatly appreciated.

George


Mar 23 '06 #3

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

Similar topics

2
by: Daven Thrice | last post by:
Hi, I've converted the tables from an old Access application to MySql format. I then linked the tables into access using MyODBC and everything works great (on my computer). For now, I want to...
6
by: Bernd Koehler | last post by:
Hi: I am a EE prof currently teaching an IT course. One the assignments students recently completed was designing a small MS Access Database. I have two submissions that are remarkably...
2
by: John C | last post by:
I am trying to develop a access database version 2002 from scratch and I am a novice programmer and need much direction. I have been researching and studying about relational database design and...
1
by: MyndPhlyp | last post by:
I am about to completely lose what is left of my poor mynd! The historical dissertation gets rather verbose, so I hope you can wade through it all. I really need some help on this one or I'm...
7
by: Dave Smithz | last post by:
Hi There, Having last developed an Access DB for a client about a year ago I have today received a specification that I need to (today ideally) give an indication of how much I would charge and...
1
by: Julia | last post by:
Hello there. I have a question somewhat related to this topic, and I don't know where else to go. I hope somebody can help. I've created a database in access, that I'd like to share with less...
5
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
5
by: Sam | last post by:
Hi, I have one table like : MyTable {field1, field2, startdate, enddate} I want to have the count of field1 between startdate and enddate, and the count of field2 where field2 = 1 between...
1
by: tezza98 | last post by:
I need some help. Im using a dtsrun command to import 9 tables into an Access database, most of the tables have about 1000 rows, but one has 20000+ rows and grows everyday. Im Using Access 2003...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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
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
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...
0
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...

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.