If your using VB.NET or C#.NET the following link is your end-all resource! ... The following is if you're using VB.NET: AccessODBC Standard Security: ... Workgroup: ... OLEDB, OleDbConnection (.NET) Standard security: ... Workgroup (system database): ... With password: ... DSN DSN: ... File DSN: ...
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.
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.
I will try to describe more clearly my problem: I am working on my Excel workbook and I create a button trying to connect to Access database or Oracle database that I already created datasource name for those 2 database in ODBC window. However, when I write the code like this: Set db = DBEngine.Workspaces(0).OpenDatabase("", , , "ODBC;") this open an ODBC window and let me select a datasource name. When I select an Oracle datasource name, the connection is successful. However, when I select an Access datasource name, I got the message error <<You cannot use ODBC to import from, export to, or link an external Microsoft Jet or ISAM database table to your database. (Error 3423)>>
So, My first question is why I cannot access to Access database??
Second, I trie to test to connect to Oracle/Access database by passing the datasource name as follow:
Set db = DBEngine.Workspaces(0).OpenDatabase("Oracle7", , , "DSN=Oracle7; DBQ=sqn2_mars; UID=MyuserId; PWD=Mypwd"), the effect is the same as if my first example on the top.
Hi Tekmaven, I did'nt declare my DbEngine. As I know DbEngine is the top level object in the DAO and we can use without declaring it.
Hi aeinstein, My problem is when I trie to connect to Access database.
Hi cscgal, I have compied my code and there is no error syntaxe that's why it open the ODBC window and let me select my datasource name.
Thank All for your response, I am looking for all your new response days and days :p)
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!
First of all, I don't see the file type "Access database" in my Excel Worksheet.
Secondly, I don't want to access my database manually like you propose File/Open....etc.. I need to program it by clicking on a button, the user can recuperate datas in a table and display them on the Excel worksheet.
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.
I am new to VB.Net and have a question. I am trying to connect VB.Net to Access. What I want to do is , when i select the database name, I want to popup the tables in the database...when one of the table is seleted, then the fields in the table should pop up...Can someone tell me how to go about it .
I've got a problem with this program.It only saves one data at time.What shall I do with it? Private Sub cmdsave_Click()
And with this program I couldn't search a data I wanted.Pls somebody help me! End Sub Private Sub cmdsearch_Click() Dim stremployeeName As String Dim strpaysheet As Variant stremployeeName = InputBox("Please enter empid") strpaysheet = datPrimaryRS.Recordset.Paysheet datPrimaryRS.Recordset.Find "CompanyName Like " & _ Chr(39) & stremployeeName & "*" & Chr(39) If datPrimaryRS.Recordset.EOF Then datPrimaryRS.Recordset.Paysheet = strpaysheet MsgBox stremployeeName & " not found." End If End Sub
Check this out: Visual Basic Database Guide. It explains in detail how to connect to different databases (including Microsoft Access, SQL, Oracle). I think it should help you get a great understanding of VB and data access.