![]() |
access database (adodb)from excel vba
hi all,
may i know the follow to connect to database able to define in VBA (excel)? i tried to use but when run i got the message compile error: user defined type not defined at Dim rstest as adodb.recordset if this cannot be done in VBA, what is the alternative to access database from excel? please advise. thank you very much Public cnsql As ADODB.Connection Sub Main() Set cnsql = New ADODB.Connection With cnsql ..Provider = "xx;" & _ "Data Source=xx;" & _ "Initial Catalog=xx;" & _ "User Id=xx;" & _ "Password=xx" ..Open End With End Sub private sub Dim rstest As ADODB.Recordset Set rstest = New ADODB.Recordset With rstest ..ActiveConnection = xx ..CursorType = adOpenKeyset ..LockType = adLockOptimistic ..Open "sql statement"'" End With |
All times are GMT +1. The time now is 04:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com