Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, November 22, 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: The ADO Connection OpenSchema Method works for Admin but not other users
Chris Wolf
Posts: 3
 
The ADO Connection OpenSchema Method works for Admin but not other usersYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Apr 08 11:47 AM
Hi Everyone,

I am using the ADO Connection OpenSchema Method to get a list of columns from the SalesLogix database.
This works fine if I use the admin username in my connection string but if I use any other user then this function call will lockup Visual Foxpro and never return. No error messages or anything.

The other strange thing is that I can get a list of tables with OpenSchema using any username but can only get columns if I use the admin user.

Any ideas?

Thanks!!!
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: The ADO Connection OpenSchema Method works for Admin but not other usersYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Apr 08 7:10 AM
Are you using the SLX OLE-DB provider? If so.. the user name ADMIN will work and any other user name setup in the SLX Administrator. Security will be applied to each login as well.

We use FoxPro on occasion as well and there were a few things I had to do to get the SLX OLE-DB provider to work. Below is a procedure used to create a connection and execute a query

PROCEDURE l_SLXOpen()
* This script handles the ADO Connection and uses a CursorAdapter object
* to retrieve data to a cursor.
PUBLIC oCA as CursorAdapter
LOCAL oConn as ADODB.Connection
LOCAL oRS as ADODB.Recordset
LOCAL oException AS Exception
LOCAL cConnString
LOCAL llReturn

llReturn = .t.

* Handle connections - insert connection code
cConnString = [Provider=SLXOLEDB.1assword=userpasswordersist Security Info=True;User ID=admin;Initial Catalog=SALESLOGIXDBNAME;Data Source=SLXSERVERNAME;Extended Properties="PORT=1706;LOG=ON"]

TRY
oConn = createobject('ADODB.Connection')

* Ensure that you handle userid and password if not
* specified in connection string.
* ex. oConn.Open(cConnString, userid, password)
oConn.Open(cConnString)

oRS = CREATEOBJECT("ADODB.Recordset")
oRS.DataSource.CursorLocation = 3 &&adUseClient
oRS.DataSource.LockType = 3 &&adLockOptimistic
oRS.ActiveConnection = oConn

oCA=CREATEOBJECT("CursorAdapter")
oCA.DataSourceType = "ADO"
oCA.DataSource = oRS
oCA.MapBinary = .T.
oCA.MapVarchar = .T.

oCA.Alias = "A_ADDRESS"
oCA.SelectCmd = "SELECT a.addressid, a.address1, a.address2, a.city, a.county, a.state, c_latitude, c_longitude, ISNULL(a.postalcode,'') AS postalcode, ISNULL(CASE LEFT(a.entityid, 1) WHEN 'C' THEN b.workphone ELSE c.mainphone END, '') AS phone FROM address a" + ;
" LEFT JOIN contact b ON a.entityid = b.contactid" + ;
" LEFT JOIN account c ON a.entityid = c.addressid"

IF !oCA.CursorFill()
* Replace with error code here
LOCAL laError
DIMENSION laError[1]
AERROR(laError)
MESSAGEBOX(laError[2])
llReturn = .f.
ELSE
* Replace with user code here. Code below allows for
* you to edit and send updates to the backend.
LOCAL laFlds,lcStr,lnFldCount,i
DIMENSION laFlds[1]
lnFldCount=AFIELDS(laFlds)
lcStr=""
FOR i = 1 TO lnFldCount
lcStr = lcStr + laFlds[m.i,1] + ","
ENDFOR
oCA.UpdatableFieldList = lcStr
ENDIF

CATCH TO oException
* Replace with exception handling code here
llReturn = .f.
MESSAGEBOX(oException.Message, 48, 10000)
ENDTRY

RETURN llReturn

ENDPROC && l_SLXOpen

[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: The ADO Connection OpenSchema Method works for Admin but not other usersYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Apr 08 7:13 AM
The =p are actually an = and p put together.
[Reply][Quote]
Chris Wolf
Posts: 3
 
Re: The ADO Connection OpenSchema Method works for Admin but not other usersYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Apr 08 8:53 AM
Hi John,

First off, thanks for the reply!

I am using the SLXOLEDB.1 provider, below is the code that I am testing with. As I said, if I use the first admin login I can use OpenSchema to get the columns but if I use lee or Dan (the sample users) OpenSchema will just hang Foxpro and I have to use Task manager to close. No useful return values or exceptions are given.


* Test Code

*lcConn = 'Provider=SLXOLEDB.1assword=""ersist Security Info=False;User ID=admin;Initial Catalog=SALESLOGIX_EVAL;Data Source=SERVER;Extended Properties="PORT=1706;"'
lcConn = 'Provider=SLXOLEDB.1assword=""ersist Security Info=False;User ID=lee;Initial Catalog=SALESLOGIX_EVAL;Data Source=SERVER;Extended Properties="PORT=1706;"'

ADOColumns(lcConn)
browse


FUNCTION ADOColumns(tcConnString)
local loConnection, llReturn, loRS

#define adSchemaColumns 4
#define adSchemaTables 20
loConnection = createobject('ADODB.Connection')
loConnection.ConnectionString = tcConnString

try


loConnection.Open()
* Get a list of all columns
loRS = loConnection.OpenSchema(adSchemaColumns)
loRS.MoveFirst()

llReturn = .T.

catch to loException

messagebox('Error Number: ' + TRANSFORM(loException.ErrorNo) + '-' + loException.Message)
return .F.

endtry

if not llReturn OR vartype(loRS) <> 'O'
return .F.
endif

lcCursor = SYS(2015)

* Convert ADO recordset to VFP cusor using CursorAdapter
oCA = CREATEOBJECT("CursorAdapter")
oCA.DataSourceType = "ADO"
oCA.Alias = lcCursor
oCA.CursorFill(.F., .F., -1, loRS)

* Detach cursor so it still be open after CursorAdapter is destroyed
llSuccess = oCA.CursorDetach()
oCA = NULL

if not llSuccess

aerror(laError)
messagebox('Error Number: ' + TRANSFORM(laError[1]) + '-' + laError[2])
return .F.

endif

loRS.Close()
return .T.
ENDFUNC
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: The ADO Connection OpenSchema Method works for Admin but not other usersYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Apr 08 2:15 PM
It doesn't appear as though you are supplying a password for user lee. Maybe that is the case??? If there is no password try omitting the password parameter. If there is a password don't surround it with parenthesis (") although I don't think this matter. Also, try changing Persist Security Info to True.

John G.
[Reply][Quote]
Chris Wolf
Posts: 3
 
Re: The ADO Connection OpenSchema Method works for Admin but not other usersYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Apr 08 2:43 PM
Alas, still the same results even with a password and 'Persist Security Info' set to True.
[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/22/2024 9:39:52 PM