472,127 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Accessing Databases

I have a few questions about databases. I would like to load only certain
records into a datagrid. For an example, with a list of customers I want to
only load the customers from California so in my SQL statement I say..

SELECT * FROM customers WHERE state = 'CurState'

I want CurState to be a variable that I can change in my program. Now if I
use the OleDBDataAdapter how do I pass that variable to the database?

also....

Is there a way I can open a connection to the database in my main form and
leave it open until I exit my application? What I am doing is using multiple
datagrids on different forms. Do I need a OleDbDataConnection,
OleDbDataAdapter and a Dataset on each form with a datagrid or can I do this
one time on the main form and have the other forms read the different tables
in the dataset on the main form?

I hope I explained this well enough. Thank you for any help you can give me.

Nov 21 '05 #1
2 1054
Debbie,

SELECT * FROM customers WHERE state = @CurState

Have than a look for the OleDb parameter class to fill that
http://msdn.microsoft.com/library/de...classtopic.asp

Is there a way I can open a connection to the database in my main form and
leave it open until I exit my application? What I am doing is using multiple datagrids on different forms. Do I need a OleDbDataConnection,
OleDbDataAdapter and a Dataset on each form with a datagrid or can I do this one time on the main form and have the other forms read the different tables in the dataset on the main form?

With an access database that is the connection approach a good approach,
with any other database not.

To use one dataset means that you should place the dataset global using a
shared class or whatever. Or give all the time the reference of the dataset
to the forms which is using that when it is instanced.

(By instance by creating an overloaded Sub New)

I hope this helps?

Cor
Nov 21 '05 #2
Thank you Cor for your help. I appreciate it very much.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uU**************@tk2msftngp13.phx.gbl...
Debbie,

SELECT * FROM customers WHERE state = @CurState

Have than a look for the OleDb parameter class to fill that
http://msdn.microsoft.com/library/de...classtopic.asp

Is there a way I can open a connection to the database in my main form and leave it open until I exit my application? What I am doing is using multiple
datagrids on different forms. Do I need a OleDbDataConnection,
OleDbDataAdapter and a Dataset on each form with a datagrid or can I do

this
one time on the main form and have the other forms read the different

tables
in the dataset on the main form?

With an access database that is the connection approach a good approach,
with any other database not.

To use one dataset means that you should place the dataset global using a
shared class or whatever. Or give all the time the reference of the

dataset to the forms which is using that when it is instanced.

(By instance by creating an overloaded Sub New)

I hope this helps?

Cor

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Benedictum | last post: by
3 posts views Thread by Scott Castillo | last post: by
3 posts views Thread by TS | last post: by
2 posts views Thread by Douglas Harber | last post: by
reply views Thread by leo001 | last post: by

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.