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 May 8th, 2008, 07:16 PM
Registered User
 
Join Date: Apr 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bad Connection String

Hello,

I have SQL Server and a VBA Access application. I also have a ODBC System DSN data source named LAVA. The connection test is good. However, when I use ADODB to connect, connection appears to be opened, but I get a "Operation is not allowed when object is closed". Any suggestons? Here is the code:

   Dim rst As ADODB.Recordset
   Dim cnn As ADODB.Connection

    Set cnn = New ADODB.Connection
    cnn.Open "DSN=LAVA;"

    Set rst = New ADODB.Recordset
    rst.Open "GIS_Data", cnn, adOpenForwardOnly, adLockReadOnly

    Dim fld As ADODB.Field
    For Each fld In rst.Fields
        Debug.Print fld.Name
    Next

    cnn.Close

 
Old May 9th, 2008, 10:18 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Look up the ConnectionString article in VBA Help. I don't think you are using the correct syntax. It is odd that SQL Server did not throw you an error:

cnn.ConnectionString = "Data Source=LAVA;"
cnn.Open



mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old May 9th, 2008, 07:36 PM
Registered User
 
Join Date: Apr 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I should mention that this DB is in SQL Server Express. I am using Windows Authenication mode.

"Provider=sqloledb;" & _
  "Server=localhost;" & _
  "Database=LAVA;" & _
  "Trusted_Connection=true"

I get: "The user is not associated with a trusted SQL Server connection."

How do I configure my SQL Server Express to allow me in.

 
Old May 9th, 2008, 09:19 PM
Registered User
 
Join Date: Apr 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My problem is I don't know how to set my SQL Server correctly.

I see lots information on the connection string, but what I don't see is information for configuring SQL Server and Active Directory and other things that are needed for a VB application to connect to a Database. Where would I find this?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection string bex BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 August 3rd, 2008 02:16 PM
connection string nalla ASP.NET 1.0 and 1.1 Professional 2 January 23rd, 2006 04:03 AM
Connection String slgknjn VB Databases Basics 2 February 26th, 2005 03:14 AM
Connection String Help. diamond2165 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 November 7th, 2003 06:09 AM





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