DBGrid connection through ADO (SQL)

Sharad Singh

New Member
Joined
Jul 11, 2009
Messages
8
Hi All,

Can any body help me to retrieve the data from MS access table in to the DB Grid at user form through MS SQL Query.

I am trying to use ADO for the same.

Thanks,
sharad
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I'm not familier with DB grids - if that's a .NET control then you'd be better off posting in a .NET forum. Generally speaking:

1) Create a connection using a connection object or other interface. .NET has data adapter or something like that. ADO uses a connection object. MS Query is another brand of connection, based on ODBC I think.
2) load or fill the dataset object you are using (recordset, datatable, datagrid, etc. etc.)
3) do what you need to do.
4) close the connection

That's it. Frankly, Excel is a massive data grid unto itself so you don't always need to create one for it in a form.

For ADO generally it is very helpful to go to W3Schools - ADO. For ADO and Excel you can poke around at erlandsendata - but again, you sound to me like you're using .NET which is a slightly different animal (Excel userforms don't have datagrids by default - or is this something new in 2007?)

Alex
 
Last edited:
Upvote 0
Thanks a lot !

Actually the DBgrid is additional tool in Excel. In which actually we show the data in Grid format.

I don't want to show excel to users.that's why used DB grid. I will try..

Thanks,
sharad
 
Upvote 0
Sure thing. If you have more info on this tool I'd be interested ... I don't see it in the default set of controls for userforms. But this is the second post I've seen referring to such a control so it must be getting more popular.

Alex
 
Upvote 0
Alex

Right click the control toolbox and select Additional controls...

You should then get a list of controls you can add, and one of them is Microsoft DataGrid Control.
 
Upvote 0
Ah...
Thanks Norie. Excel says I don't have a license so...no joy.

Alex.
 
Upvote 0
Alex

I thought something like that might happen.:)

I don't get the 'license' thing but I do get a message saying that 'The subject is not trusted for the specified action' when I try to add a DataGrid control to a userform.

I think that has something to do with updates and KillBits (whatever they are).:)

I can't even add a simple calendar control to a userform in Excel VBA.:eek:

I've tried to fix these problems but gave up because it seemed like too much trouble - but that's probably me being lazy.

I can add the controls to forms in VB6, VB.Net, C# and Access but no luck with Excel.
 
Upvote 0
HI All,

Even I am facing the same problem when I try to select Microsoft Data grid or flexgird. moreover the DB grid is working fine. However I still not able to connect the DB grid with ADO.

Actually the problem is that,I want to show the report to user which has more then one column and rows on VBA user form it self. Which can't be possible without using such tool.. or I need to use lot of list boxes...???

currently I have used the list boxes. but with list box the problem is that ...if the text is very large then the user will not be able to read the whole text as no scroll bar is available for them. However the scroll bar option is "ON". and if the text is small the list box, then it is showing the scroll bar which is not required on that moment. I don't know why??

Please if you all have any solution on this..let me know...

Thanks,
Sharad Singh
 
Upvote 0
Sharad

Why are you trying to do this in the first place?
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top