access database

capitala

New member
Joined
Apr 22, 2005
Messages
2
Programming Experience
Beginner
i want to connect to access database (read and update) without datagrid or dataset using code
and how to like fields in database with controls on the forms
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,322
Location
Sydney, Australia
Programming Experience
10+
If you want to read values from a database straight into fields you can use OleDbCommand.ExecuteScalar(). If you want to bind fields to data, you will need to use a DataSet, or at least DataTables, with an OleDbDataAdapter or an OleDbDataReader.
 

DeBiese

New member
Joined
Apr 24, 2005
Messages
4
Programming Experience
Beginner
Do you mean that you don't want to use the wizards for making the connection, the dataapdapter and the dataset? Because it's fairly easy to code them yourself...
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,322
Location
Sydney, Australia
Programming Experience
10+
You can certainly create the data access objects in design view. It depends whether you want the variables to have Form level scope or not. I use either method, depending on the circumstances. Certainly it is a laborious execise creating a DataAdapter with four long commands in code.

What I meant was, if you want to get a single value from the database, put it in a control and not update the database again, you can use OleDbCommand.ExecuteScalar() to retrieve that value. If you want one or several rows of data from the database, the fields of which you want to put in controls and not update the database again, you can use OleDbCommand.ExecuteReader(). If you want to update the data you retrieve from the database, then you should use an OleDbDataAdapter and a DataSet, or a DataTable if you are not retrieving multiple tables. How you create the data access components is up to you.
 
Top Bottom