Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 8th, 2008, 07:16 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old May 9th, 2008, 10:18 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old May 9th, 2008, 07:36 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old May 9th, 2008, 09:19 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
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?

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.