Accessing Databases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Debbie Carter

    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 OleDBDataAdapte r 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 OleDbDataConnec tion,
    OleDbDataAdapte r 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.



  • Cor Ligthert

    #2
    Re: Accessing Databases

    Debbie,

    SELECT * FROM customers WHERE state = @CurState

    Have than a look for the OleDb parameter class to fill that

    [color=blue]
    >
    > 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[/color]
    multiple[color=blue]
    > datagrids on different forms. Do I need a OleDbDataConnec tion,
    > OleDbDataAdapte r and a Dataset on each form with a datagrid or can I do[/color]
    this[color=blue]
    > one time on the main form and have the other forms read the different[/color]
    tables[color=blue]
    > in the dataset on the main form?
    >[/color]
    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


    Comment

    • Debbie Carter

      #3
      Re: Accessing Databases

      Thank you Cor for your help. I appreciate it very much.



      "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
      news:uUA8bs1jEH A.3848@tk2msftn gp13.phx.gbl...[color=blue]
      > Debbie,
      >
      > SELECT * FROM customers WHERE state = @CurState
      >
      > Have than a look for the OleDb parameter class to fill that
      >[/color]
      http://msdn.microsoft.com/library/de...classtopic.asp[color=blue]
      >[color=green]
      > >
      > > Is there a way I can open a connection to the database in my main form[/color][/color]
      and[color=blue][color=green]
      > > leave it open until I exit my application? What I am doing is using[/color]
      > multiple[color=green]
      > > datagrids on different forms. Do I need a OleDbDataConnec tion,
      > > OleDbDataAdapte r and a Dataset on each form with a datagrid or can I do[/color]
      > this[color=green]
      > > one time on the main form and have the other forms read the different[/color]
      > tables[color=green]
      > > in the dataset on the main form?
      > >[/color]
      > 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[/color]
      dataset[color=blue]
      > to the forms which is using that when it is instanced.
      >
      > (By instance by creating an overloaded Sub New)
      >
      > I hope this helps?
      >
      > Cor
      >
      >[/color]


      Comment

      Working...