Results 1 to 8 of 8

Thread: [RESOLVED] Filling a Datagridview with an Access query ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Resolved [RESOLVED] Filling a Datagridview with an Access query ?

    Hello to everybody.
    I am trying to find an answer but no luck so far.
    I have an access query which plays flawlesly in Access.I want to use it as a source for a datagridview i use in one of my forms but....given the fact that is a rather big query with some "like" and conditions like ">3" and so on AND the fact it uses tables from 3 different mdb (not to mention is bases on other queries...i 'ill try my best to fix this) what is the best approach .

    1st case .Can i retrieve the data simply with NO oledbparameteres and NO " select * xxx where yyy like 'd' ".I think there is a issue with the Oledb connection that "omits" them.To explain better the query right now with the filters in access returns 3 rows, without the filters 30 rows,can i get just the 3 rows to do my job...
    2nd case . How should i fill a datagridview using tables from 3 different mdbs.If you can show me an example it would be life saving.

    Thanks in advance

  2. #2
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Filling a Datagridview with an Access query ?

    1st to select all data without the parametes using SELECT * it's the best way. But you can use parameters and build the query to use meta chars and if you put them it's like you have SELECT *.

    2nd .... don't read well

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Filling a Datagridview with an Access query ?

    To the 2nd option, just build three datatables and merge them if they have the same schema...
    VB.NET Code:
    1. Dt1.Merge(Dt2)
    2. Dt1.Merge(Dt3)

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Re: Filling a Datagridview with an Access query ?

    When u say merge do u mean simple merge.The case is that my query uses 6 tables from 3 different mdb.When i merge i have available all the tables???
    E.g
    Mdb1 has tbl1,tbl2,tbl3
    mdb2 has tbl4,tbl5
    mdb3 has tbl6
    with merge i will get all the tables and make a dataset?

  5. #5
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Filling a Datagridview with an Access query ?

    No, the merge command merges two data tables with the same schema, if the tables are different's you can't merge.

    You can put them in the same dataset, just use the add method.

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Re: Filling a Datagridview with an Access query ?

    i will give it a try ... although today's schedule seems a little heavy.Thanks for the help.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Re: Filling a Datagridview with an Access query ?

    Well i haven't tried yet your suggestion but i tried this.In Dataset Designer i tried to do a LEFT JOIN i need and it seems there is no way of doing this.SO my guess is that i cannot "replicate" the Access query i use and i have to go the hard way with the parameters and so on....
    Any idea.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Re: Filling a Datagridview with an Access query ?

    Well i examined my query from another prospective and now it works as it should.Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width