Solved

DSN Less connection in VBS to and Access database. Error in Set Conn...

Posted on 2013-11-11
12
503 Views
Last Modified: 2013-11-12
In the code below I get an error at Set conn1
Either server is undefined or object expected.
What am I doing wrong?


OPTION EXPLICIT

DIM Conn1, rs1, cst, strSQL1, myMail, body

' OPEN a OLE DB CONNECTION
      Set conn1 = server.CreateObject("ADODB.Connection")
      cst = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\ScheduledDBs\OUTRIDsXpert.accdb;"
      conn1.open cst
      
      'Create a Record Set with the Conn from above, then Set SQL, and then execute
      Set rs1 = Server.CreateObject("ADODB.Recordset")      
      strSQL1 = "select *  from Qry_CountRIDS-ByRSE"      
      rs1.Open strSQL1, conn1,3,3
0
Comment
Question by:Mswetsky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
12 Comments
 
LVL 9

Expert Comment

by:WebDevEM
ID: 39639815
Is that code running in a VBS file on your computer, or as an ASP page on a web server?  Its been a while since I've dealt with VBS files locally, but I think the "server." is only required if you're running in IIS.  If you're running it from a .VBS file try dropping that and using
Set conn1 = CreateObject("ADODB.Connection")

Open in new window

as shown here.
0
 
LVL 1

Author Comment

by:Mswetsky
ID: 39639869
Yes I am trying to use a vbs to read from the access db and mail a note with a table.
I changed to that but get a "provider can't be found" 800A0E7A
0
 
LVL 9

Expert Comment

by:WebDevEM
ID: 39639943
I remember that driving me nuts when I was working on Access files - Common wisdom is to make sure you're on the latest version of your programs, drivers, etc, but at some point Microsoft stopped shipping JET with their MDAC drivers.  So you need extra files that aren't installed with the latest version.

There's a good article here that may help get it installed.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 1

Author Comment

by:Mswetsky
ID: 39639986
Thank you for your patience.
It seems that accdb uses a new oledb string.
http://www.connectionstrings.com/access/ 
I tried the sample here but am still unable to get it to pass that line.
Tomorrow is a new day and I'll try then.
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 500 total points
ID: 39640539
As you saw, use Microsoft.ACE.OLEDB.12.0

This should work
OPTION EXPLICIT

DIM Conn1, rs1, cst, strSQL1, myMail, body

' OPEN a OLE DB CONNECTION
      Set conn1 = CreateObject("ADODB.Connection")
      cst = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Administrator\Desktop\ScheduledDBs\OUTRIDsXpert.accdb;Persist Security Info=False;"
      conn1.open cst
      
      'Create a Record Set with the Conn from above, then Set SQL, and then execute
      Set rs1 = CreateObject("ADODB.Recordset")      
      strSQL1 = "select *  from Qry_CountRIDS-ByRSE"      
      rs1.Open strSQL1, conn1,3,3 

Open in new window


Regards,

Rob.
0
 
LVL 1

Author Comment

by:Mswetsky
ID: 39641398
Thank you for your suggestions.
Just FYI, Running on Server 2008R2. (Don't know if that matters)
I have attached images of the current code and error.Code as suggestedError message
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 39641449
Try installing the Access database engine from here:
http://www.microsoft.com/en-au/download/details.aspx?id=13255
0
 
LVL 1

Author Comment

by:Mswetsky
ID: 39641935
I am working on a production Server and would like to avoid reinstalling Access.
You and I know of all the permissions and stuff can get broken
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39642366
Yes, but for the code to work you need a driver installed. Maybe you can build a "service" server that can run tasks like this.
0
 
LVL 1

Author Comment

by:Mswetsky
ID: 39642526
Thanks again Rob And Ed,
I believe I understand now. Sometimes I get so caught up I forget to look.

I will try and find another way to install the new drivers, or attempt to re-install Access after making a server copy during off work hours.

I really do appreciate your patience and the chance to learn.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39642806
Sure. Just keep in mind it's not the full Access product. It's just a database engine driver to facilitate data connections for requirements like this.  If you're running virtual machines, take a snapshot before installing it, just in case anything goes wrong, but it shouldn't be a problem.
0
 
LVL 1

Author Comment

by:Mswetsky
ID: 39643016
Oh I didn't realize that!  
Sort of like MDAC

Thank you for the clarification, I will feel much more confident!

It is a VM and that was my intent with a server copy.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question