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

VB.Net - connecting to Access

I've been using OdbcConnection, OdbcCommand, etc to do work associated with
an Access 2003 database - is that the best? What are the other
alternatives - and their pros/cons?

Any/all insights - much appreciated.

BBB
Jun 6 '07 #1
8 6776
On 6 Giu, 15:25, "booner" <b3boo...@yahoo.comwrote:
I've been using OdbcConnection, OdbcCommand, etc to do work associated with
an Access 2003 database - is that the best? What are the other
alternatives - and their pros/cons?

Any/all insights - much appreciated.

BBB
hi BBB,

I have been using the OleDB connection and works fine and fast.
Let me know if you need more info about that.
Tommaso
-- Datatime Universal (free) http://cam70.sta.uniroma1.it/DatatimeUniversal/
--

Jun 6 '07 #2
I've got ODBC connection working.

I guess I was looking for a breakdown of why I would use (pros/cons) Odbc or
OleDb, Sql, Ado ...

Just trying to educate myself on the options and when/why to use them.
"to**************@uniroma1.it" <To**************@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
On 6 Giu, 15:25, "booner" <b3boo...@yahoo.comwrote:
>I've been using OdbcConnection, OdbcCommand, etc to do work associated
with
an Access 2003 database - is that the best? What are the other
alternatives - and their pros/cons?

Any/all insights - much appreciated.

BBB

hi BBB,

I have been using the OleDB connection and works fine and fast.
Let me know if you need more info about that.
Tommaso
-- Datatime Universal (free)
http://cam70.sta.uniroma1.it/DatatimeUniversal/
--

Jun 6 '07 #3
You definitely want to use the OleDB connection because that allows you
to use the OleDBDataAdapter which is the BEST way to move data to and
from any OleDB database. The DataAdapter (OleDBDataAdapter,
SqlDataAdapter) forgo having to loop through data. You can use the Fill
method to retrieve data into a .Net Dataset in one shot and you can use
the Update Method to Insert and Update Data on the Database side.

The DataAdapter has revolutionized how you Read/Write data From/To any
RDBMS

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 6 '07 #4
On 6 Giu, 17:26, Rich P <rpng...@aol.comwrote:
You definitely want to use the OleDB connection because that allows you
to use the OleDBDataAdapter which is the BEST way to move data to and
from any OleDB database. The DataAdapter (OleDBDataAdapter,
SqlDataAdapter) forgo having to loop through data. You can use the Fill
method to retrieve data into a .Net Dataset in one shot and you can use
the Update Method to Insert and Update Data on the Database side.

The DataAdapter has revolutionized how you Read/Write data From/To any
RDBMS

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
I agree with Rich about the OleDb Connection. Oledb is the way to go
now.

But, if I may, I would not recommend too much the OleDBDataAdapter. In
my opinion,
in most situations one could even disregard its existence and focus on
the OleDbDataReader
directly (which is anyway used by the adapter), because more general
and flexible.

Another big advantage is given by the OleDbSchemaGuid which makes
possible
easy integration among platforms and metadata retrieval.
Tommaso
-- Datatime Universal (free) http://cam70.sta.uniroma1.it/DatatimeUniversal/
Jun 6 '07 #5
What advantages do I get by using the OleDB classes (Connection, Command)
versus their Odbc counterparts?

From what I can see - other than connection string used - the general means
for doing db work - is nearly identical.

So why use Ole vs. Odbc vs. ADO ... set of classes?

I have the general mechanics down - just not sure which set of classes get
me the most bang for the buck.

"to**************@uniroma1.it" <To**************@gmail.comwrote in message
news:11**********************@q69g2000hsb.googlegr oups.com...
On 6 Giu, 17:26, Rich P <rpng...@aol.comwrote:
>You definitely want to use the OleDB connection because that allows you
to use the OleDBDataAdapter which is the BEST way to move data to and
from any OleDB database. The DataAdapter (OleDBDataAdapter,
SqlDataAdapter) forgo having to loop through data. You can use the Fill
method to retrieve data into a .Net Dataset in one shot and you can use
the Update Method to Insert and Update Data on the Database side.

The DataAdapter has revolutionized how you Read/Write data From/To any
RDBMS

Rich

*** Sent via Developersdexhttp://www.developersdex.com***

I agree with Rich about the OleDb Connection. Oledb is the way to go
now.

But, if I may, I would not recommend too much the OleDBDataAdapter. In
my opinion,
in most situations one could even disregard its existence and focus on
the OleDbDataReader
directly (which is anyway used by the adapter), because more general
and flexible.

Another big advantage is given by the OleDbSchemaGuid which makes
possible
easy integration among platforms and metadata retrieval.
Tommaso
-- Datatime Universal (free)
http://cam70.sta.uniroma1.it/DatatimeUniversal/


Jun 6 '07 #6
Here is a quicky sample of the OleDB class used with an Access mdb

Imports System.Data.OleDb
Imports System.Data

Public Class Form7
Dim conn As OleDbConnection, da As OleDbDataAdapter
Dim ds As DataSet, curMgr As CurrencyManager

Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0; Data Source =
C:\Code\testAcc\db2test.mdb"
da = New OleDbDataAdapter
ds = New DataSet
da.SelectCommand = New OleDbCommand
da.SelectCommand.Connection = conn
da.SelectCommand.CommandType = CommandType.Text
da.SelectCommand.CommandText = "Select * from Table1"
da.Fill(ds, "tbl1")
curMgr = CType(Me.BindingContext(ds.Tables("tbl1")), CurrencyManager)
curMgr.Position = 0
tssL3.Text = curMgr.Count.ToString
tssL2.Text = (curMgr.Position + 1).ToString
dgrv1.DataSource = ds.Tables(0)
End Sub

Private Sub dgrv1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dgrv1.Click
'--this will display the number of the record you are on
'--in the Datagridview - same as a table or query in Acc
tssL2.Text = (curMgr.Position + 1).ToString
End Sub
End Class

Note: tssL2 and tssL3 are labels on a statusStrip (my naming
convention). The statusStrip is the control that replaces the StatusBar
- much more horsepower. dgrv1 is a DatagridView control (the equivalent
of a subform, but way more horsepower and flexibility).

You could use the OleDBDataReader or DataAdapter. The OleDBDataReader
doesn't have the Fill method, but if you don't need to fill a table to
view in a DatagridView control, then the Reader is probably more
efficient.

This sample may not look like much, but if you apply it to a large
project, you will end up writing way less code using the OleDB class
than the ODBC class. THe ODBC class is mostly for legacy stuff, like
for DBF tables. Access is an OleDB application, so you should take
advantage of the improvements OleDB offers over ODBC.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 6 '07 #7
On 6 Giu, 20:07, "booner" <b3boo...@yahoo.comwrote:
What advantages do I get by using the OleDB classes (Connection, Command)
versus their Odbc counterparts?

From what I can see - other than connection string used - the general means
for doing db work - is nearly identical.

So why use Ole vs. Odbc vs. ADO ... set of classes?

I have the general mechanics down - just not sure which set of classes get
me the most bang for the buck.
You may also want to take a look ar these.

http://www.4guysfromrolla.com/webtech/063099-1.shtml
http://www.4guysfromrolla.com/webtech/070399-1.shtml

In any case switching to oledb you will experience advantages,
especially
if you ever need to write (general) code to be used against different
dbms

[to me, for programming purposes, the decisive argument is the
oledbschemaguid:
I would use it even if it performed slower, just because of the
metadata available]

T

Jun 6 '07 #8
Thanks.

They threw me off by calling it OLE - clearly, with .net - not my father's
OLE (from back in the day).

"to**************@uniroma1.it" <To**************@gmail.comwrote in message
news:11*********************@g37g2000prf.googlegro ups.com...
On 6 Giu, 20:07, "booner" <b3boo...@yahoo.comwrote:
>What advantages do I get by using the OleDB classes (Connection, Command)
versus their Odbc counterparts?

From what I can see - other than connection string used - the general
means
for doing db work - is nearly identical.

So why use Ole vs. Odbc vs. ADO ... set of classes?

I have the general mechanics down - just not sure which set of classes
get
me the most bang for the buck.

You may also want to take a look ar these.

http://www.4guysfromrolla.com/webtech/063099-1.shtml
http://www.4guysfromrolla.com/webtech/070399-1.shtml

In any case switching to oledb you will experience advantages,
especially
if you ever need to write (general) code to be used against different
dbms

[to me, for programming purposes, the decisive argument is the
oledbschemaguid:
I would use it even if it performed slower, just because of the
metadata available]

T

Jun 8 '07 #9

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

Similar topics

4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
5
by: bill | last post by:
I am having difficulties connecting to a remote Sql server database in VB.net. Lets say my remote server is found at 255.255.255.255 and its name is MyServer. The database is called MyDatabase....
5
by: Sebastian | last post by:
I'm using the following code to connect to an access 2000 database. (with reference to adodb) Public DBvar As New ADODB.Connection() DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data...
5
by: Al | last post by:
Hi, I am looking for sample VB.net code for working with Access 97 database. I know how to work with SQL but I dont know how to read and writ into access 97. Any help is very much appreciated. ...
4
by: kthiagar | last post by:
Hi I am trying to connect to a password protected access file from VB.NET. I have no problem in connecting to Access, if I remove the password. This is what I am doing: In the server explorer,...
3
by: Laurence | last post by:
Hi there, Does somebody know the efficent way to connect DB2/400? Through iSeries Access ODBC/OLEDB driver or DB2 Connect? Which will more fast and efficent? In addition, does DB2 Connect use...
3
by: Chris | last post by:
Don't know if there is a simple solution for this one or not. When running SQL server on a machine with 2000 loaded and the complete SQL package I don't have any issues. Now I'm trying to login...
3
by: BigZero | last post by:
hello i m new to php i m working on project that has interface with simple html and php i m thinking to use i got some problem with the connecting to DB here is the code for connecting db ...
2
by: franc sutherland | last post by:
Hi, I am trying to build a database in Access 2003 which can connect to information in a SAGE system. Should I use ODBC, and if so, which driver is required? Is there another way of...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
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
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,...

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.