Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, November 26, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 External Development Forums - SalesLogix OLEDB Provider
Forum to discuss using the SalesLogix OLE DB Provider from external applications (including usage of built-in provider procedures). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix OLEDB Provider | New ThreadView:  Search:  
 Author  Thread: Need to make connection within application not using Application.GetNewConnection
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Need to make connection within application not using Application.GetNewConnectionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 07 8:31 AM
I need to run a script as an agent and it is failing whenever 'Application....' is called. I would like to create the connection without hardcoding the actual DB name or hardcoding passwords so I can move from Dev to production without editing the scripts or putting passwords in plain text in the code. Is this possible and if so what is the best method to do this? I have used a connection string created from a .udl file before, but this required some hard coding if I recall..
Thanks
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need to make connection within application not using Application.GetNewConnectionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 07 11:19 AM
First create the UDL file by creating a new text file and rename it to something like MyConnection.UDL. Then double-click it and configure the connection details.

To create a new connection object and set the connection for it, you just need a few short lines of code:

Dim conn 

Set conn = CreateObject("ADODB.Connection")
conn.Open "File Name=C:\MyConnection.udl"


That is it. Make sense?
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need to make connection within application not using Application.GetNewConnectionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 07 11:24 AM
You could drop that in an include script like this to make it a bit more reusable:

Function GetNewConnection(ByVal UdlFile)
Set GetNewConnection = CreateObject("ADODB.Connection")
GetNewConnection.Open "File Name=" & UdlFile
End Function


Now you can easily use it like this:

Set rs = GetNewConnection("C:\MyConnection.udl").Execute("select * from sometable")
While Not rs.EOF
'...
Wend


Or any way you'd use the built in Application.GetNewConnection, just pass the UDL file to it.
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Need to make connection within application not using Application.GetNewConnectionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 07 1:57 PM
So if I am going to run this from an agent, would I put the UDL file on the sync server?
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need to make connection within application not using Application.GetNewConnectionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 07 1:59 PM
Quote:
Originally posted by Steve Knowles

So if I am going to run this from an agent, would I put the UDL file on the sync server?


I don't use Agents, but I believe that is correct.
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Need to make connection within application not using Application.GetNewConnectionYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 07 2:46 PM
That did work with the UDL on the sync server. I actually decided to put the connection string in the code on the form, but thanks for the cool trick.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/26/2024 8:26:17 AM