[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
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 :)
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:
Dt1.Merge(Dt2)
Dt1.Merge(Dt3)
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?
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.
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.
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.
Re: Filling a Datagridview with an Access query ?
Well i examined my query from another prospective and now it works as it should.Thanks