Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote Connection to MSSQL through vbscript error

Status
Not open for further replies.

ndnalibi

MIS
Nov 12, 2002
61
US
Hello,

I have a vbscript that is non-asp. It is run in a program called EFI-Logic that is an ERP. EFI-Logic caonnects to our MSSQL database for normal operation. The problem is that on
some computers I get the following error:

Source: ADBO.Connection
Safety Settings on this computer prohibit accessing a data source on another domain.

I've gone through the security settings in IE and enabled "access database from across domain", added the server to trusted , then local intranet. I even tried mapping the drive first and accessing it that way.

Any other suggestions? Is there a way to use the existing ODBC connection in the script rather than creating a new connection? Or perhaps this is conflicting with the existing connection.

It works on my Win 2000 IE6.028 laptop, but fails on a winXP ie7 and winXP
IE6.029

Code:
' Updates the JobLayout table StockMCCDesc with the value in MatlCostCntr.MCCDescription

Sub HandleGridChanges(GridName, ControlName, Operation, Table, Column, NewValue, NumberKeys, KeyColumnValues, CopyKeyColumnValues)
	Dim strConn
	strConn="DSN=Liberty Database; User ID=billo; Password=noldor"
	Dim rs
	Dim MCCDesc
	Dim strJob
	Dim wdt
	Dim lgt
	strJob = Logic_KeyColumns(0)
	Dim objCN
	Set objCN=CreateObject("ADODB.Connection")
	Dim strSQL
	strSQL = "SELECT MCCDescription FROM MatlCostCntr WHERE MCCN = " & NewValue & ";"
	objCN.Open strConn

		If Operation = "update" and Column = "StockMCCN" Then
		rs= objCN.execute(strSQL)
		MCCDesc= rs("MCCDescription")
		'wdt = rs(Width)
		'lgt = rs(Length)
		Stockf.ValueKeyed("MCCD",3,KeyColumnValues(0),KeyColumnValues(1),KeyColumnValues(2),KeyColumnValues(3),KeyColumnValues(4)) = MCCDesc 
		End If		

End Sub

Thanks,

Bill O'Connell
 
yes, you can use an existing DSN. here is a sample:

Code:
'Create an ADO connection object 
Set adoCon = Server.CreateObject("ADODB.Connection") 

'Set an active connection to the Connection object using DSN connection 
adoCon.Open "DSN=guestbook" 

'Create an ADO recordset object 
Set rsGuestbook = CreateObject("ADODB.Recordset") 

'Initialise the strSQL variable with an SQL statement to query the database 
strSQL = "SELECT tblComments.* FROM tblComments;"

'Open the recordset with the SQL query 
rsGuestbook.Open strSQL, adoCon 

'Loop through the recordset 
Do While not rsGuestbook.EOF 
     Wscript.Echo (rsGuestbook("Name")) 
     Wscript.Echo (rsGuestbook("Comments"))
     Wscript.Echo
     'Move to the next record in the recordset
     rsGuestbook.MoveNext
Loop 

'Reset server objects 
rsGuestbook.Close 
Set rsGuestbook = Nothing 
Set adoCon = Nothing

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Hi Mark,

Thanks for your help.

At first I got a "Object Required: Server" error using your connection code.

Some research turned up a few solutions, and I worked around that in a couple of different ways:

1.Removing the server. before CreateObject (read was not needed on client side vbscripts
2.Adding ,2,3 after the rsguestbook.open strsql, adoCon

but the end result was the same Safety settings error.

It's driving me nuts! The database connection works fine for my 2000 based laptop, and fine with XP for other programs.

Any other suggestions?

Thanks,

Bill
 
I would verify that you don't have local policies overriding the local setting in IE.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I can not find any overriding policies. Is it possible that it is an MDAC version issue? I am running MDAC 2.6 on the working machine, 2.8 on the offending machines.

Is there a way to change the MDAC versions used in vbscripts? or am I following a dead-end.

Bill
 
Not sure but I would try to get everything on the latest MDAC.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top