What version of VB are you using? And, what is DBEngine declared as?
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
dont know much about VB @ all but let me ask u a coupla ???...
what db are u trying to access the Access DB from?
does it support ODBC via VB directly, or do you need connection services, managers &/or drivers?
is it necessary to establish a connection authorization from your destination db to your external source (ODBC) db PRIOR to attempting connection?
i come from the Lotus Notes/Domino world, whereby the answers to all of the above is a resounding YES, but i do not know if that is universally true.
aeinstein
Team Member - aka kaynine
645 posts since May 2002
Reputation Points: 186
Solved Threads: 8
Just wanna check up on something ...
Personally, I've never connected to a database via ODBC. However, just wanna check:
You say you used the command
Set db = DBEngine.Workspaces(0).OpenDatabase("dbsourcename", ,"DSN=dbsourcename;UID=MyUID;PWD=Mypassw")
to connect to the database. You *DID* replace the items in bold with your own variables, right? Just making sure! ;)
Also ... one more thing ... between dbsourcename and DSN=, you have two commas. Is it supposed to be like that. You use a ; to separate all of the other parameters.
Just a lil syntax check you may wanna look at!
cscgal
The Queen of DaniWeb
19,427 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
Dani -
Thats wrong :-P. When you use a DSN, you do not need to fill in any other information. The DSN stores everything for you.
Also you seperate connnectionstring items with a ;
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
What I'm saying is this is the code that ChristinaOrchid used. It doesn't matter whether they're using extraneous info, etc. It might be a syntax error (e.g. they used a comma instead of a semi-colon.)
You just said you don't need to fill in any other info? Well they did (as you can see). Maybe that's the problem?
Just trying to troubleshoot the code THEY used from a syntax error standpoint.
cscgal
The Queen of DaniWeb
19,427 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
If your using VB.NET or C#.NET the following link is your end-all resource!
http://www.connectionstrings.com/
The following is if you're using VB.NET:
Access
ODBC
Standard Security:
"Driver={Microsoft Access Driver (*.mdb)};Dbq=\somepath\mydb.mdb;Uid=Admin;Pwd=asdasd;"
Workgroup:"Driver={Microsoft Access Driver (*.mdb)};Dbq=\somepath\mydb.mdb;SystemDB=\somepath\mydb.mdw;" OLEDB, OleDbConnection (.NET)
Standard security:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=asdasd;"
Workgroup (system database):
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;","admin", ""
With password:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;","admin", ""
DSN
DSN:
"DSN=myDsn;Uid=username;Pwd=;"
File DSN:
"FILEDSN=c:\myData.dsn;Uid=username;Pwd=;"
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
Huh? Are you tring to import data from a table? If you are, just selecet File->Open and change the file type to "Acess Databases." You will recieve a wizard that will automatticly import the data for you!
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
Then why are you using Excel? Why not just use Access? You can accomplish this by creating a "Form".
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
Well, if you want to synchronize Access information from an Excel sheet (Which is what I think you want to do), you don't need any code. Synchronizing it with a sheet automatically sounds like a much better way to
go rather than a button that does it (unless you want to do call a vbscript, but it's not necessary in this case). A user can just go to the sheet and it'll be there. I've done this before, but not in Excel 7.0.
If you want to synchronize a sheet in your workbook with output from an ODBC datasource, go to the menu Data -> Get External Data -> New Database Query. If you don't have Microsoft Query, you might be asked to insert the CD and install this feature. If it all goes well, you should get a window where you get to pick a data source. Choose one you created and click ok. After that, you'll get another window where you can pick what columns you want. Select what columns and click on the -> button. Click next. The following dialogs are
self explanatory (sort by, etc.). The last dialog (Query Wizard - Finish) you can select "Return Data to Microsoft Excel." You can save the query if you want to by pressing on the button "Save Query." Click on finish.
After you do all that, you'll get a dialog that says "Returning External Data to Microsoft Excel." Select existing worksheet (assuming it's blank). Click ok. The information will be imported to your current sheet. The data is dynamic however. Any change you do in your ODBC database, it will update in Excel automatically. You can right click and hit Refresh. If you want you can right click on one of the fields and go to External Data Range Properties. There you can control the Refresh rate.
samaru
a.k.a inscissor
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
I hope what you want is NOT a client in Excel to insert information into an Access database. There are better solutions than trying to do this, but something like that can be done.
samaru
a.k.a inscissor
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18