Solved

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

Posted on 2013-11-11
12
493 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
  • 6
  • 4
  • 2
12 Comments
 
LVL 9

Expert Comment

by:WebDevEM
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:Mswetsky
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now