List Info

Thread: Database access without using a dataset




Database access without using a dataset
user name
2006-06-21 12:52:22
> I need to access an ODBC database (Connx), running a
single query at a
time.
> I DO NOT want to set up or fill a dataset because of
the immense size of
> this database.  How do I set up a database connection
in .Net 2.0 so I can
> open a connection, run a query on the database, and
close the connection,
> retrieving only the data I am querying for?  Every time
I try to use the
> Data Source Wizard, it tries to set up a dataset.

Take a look at this example:

    http://www.vb-helper.com/howto_net_get_set_data_value.
html

It makes a database connection. When you click a button, it
connects and
calls ExecuteScalar to execute a query that returns a single
result. A
different button calls ExecuteNonQuery to executes an UPDATE
statement.

You can also use ExecuteReader to retrieve more than one
record but you
certainly don't need to read the whole database. Here's an
example that does
this:

    http://www.vb-helper.com/howto_net_db_load_listbox.html

Note that you could also use a DataSet to read just the
records that you are
selecting, not the whole database. This example uses a
SELECT statement to
control the rows displayed in a DataGrid.

    http
://www.vb-helper.com/howto_net_datagrid.html

HTH,

Rod

Rod Stephens, Author of "Visual Basic 2005
Programmer's Reference"
http://www.v
b-helper.com/vb_prog_ref.htm
Sign up for the free VB Helper Newsletters at
http://www.v
b-helper.com/newsletter.html

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )