Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2004, 11:43 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB.NET DAO DSN???

Heya Everyone,
              How are we all?
I have a bit of a problem...
I'm using WinXP Service Pack 2 with vs.net
I'm trying to create a DSN connection to an Access 2000 Database using an asp.net form as the interface.
I have referenced the DAO 3.6 Library... But I keep getting an error with I compile...

####################
The source code is:
####################

Dim Dbs As DAO.Database
Dim Connect As New DAO.PrivDBEngine

Public Function OpenDatabaseConnection(ByVal TableName As String) As Boolean
        Dbs = connect.OpenDatabase("", False, False, _
        "DSN=Bulletin_Boards;UID=test;PWD=test;")

        Dbs.OpenRecordset(TableName, DAO.RecordsetTypeEnum.dbOpenDynaset _
        , DAO.RecordsetOptionEnum.dbInconsistent _
        , DAO.LockTypeEnum.dbOptimistic)
        Return True
End Function


######################
The error Message is:
######################

Server Error in '/Work/Bulletin_Boards' Application.
ODBC--connection to 'Bulletin_Boards' failed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: ODBC--connection to 'Bulletin_Boards' failed.

Line 15: Dbs = connect.OpenDatabase("", False, False, _
Line 16: "DSN=Bulletin_Boards;UID=test;PWD=test;")



Could someone please help me?
I have no idea what I have done wrong?
Slightly lost... Looking for help...
Thanking you in advance...


 
Old November 17th, 2004, 04:48 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is basic, but did you create the DSN through your Data Sources? If so, did you test the connection? Did the connection work?

If you answered yes to all three of these, then I am not sure where to start, other than your UID and PWD.

The way I handle this sort of connection would be:

Dim stUID As String = "****"
Dim stPWD As String = "****"

Then ...

Dbs = connect.OpenDatabase("", False, False, _
        "DSN=Bulletin_Boards;", stUID, stPWD)

I have done this in VBScript, and I had to create the connection first, then I used this syntax...

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "DSN=AssetManagement;", strUserName, strPassword

I know these are different connection types, but please note the difference in syntax surrounding the UID and PWD.

The connection may be failing because you are not properly passing these credentials.



mmcdonal
 
Old November 18th, 2004, 07:08 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I created the connection and tested it... It worked fine... I have also tried it without UID and PWD (Updated the DSN as well to include no user or password), but still nothing... I will keep trying... Thank you for your help... It is muchly appreciated...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect SQL Server 2k with VB from DSN and DBQ ayan.mukherjee SQL Language 0 February 12th, 2008 02:26 AM
VB5.0 to VB .Net upgradation issue related to DAO setu VB How-To 1 October 10th, 2007 03:15 PM
Creating DSN dynamically in VB Tany VB Databases Basics 0 March 9th, 2006 10:25 AM
System DSN Using in ASP.net ramacvs ADO.NET 0 September 14th, 2004 02:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.