ADO automation Select query problem

KisuKisu Member Posts: 381
Hmm I'm practising using ADO with navision as I'm needing it later to retreave data from external database (which will be located in same domain) but somehow I dont get the SELECT statement to work
IF ISCLEAR(lADOConnection) THEN
  CREATE(lADOConnection);

lADOConnection.ConnectionString := 'Driver={SQL Server}; Server=ServerX; Database=DatabaseX; UID=UserX; PWD=PasswordX';

lADOConnection.Open;

IF ISCLEAR(lADOCommand) THEN
  CREATE(lADOCommand);

lvarActiveConnection := lADOConnection;
lADOCommand.ActiveConnection := lvarActiveConnection;

lADOCommand.CommandText := 'SELECT * FROM [dbo].[User]';
lADOCommand.Execute;

ltxtResult := FORMAT(lADOCommand.Parameters.Item('@Result').Value);   

MESSAGE(ltxtResult); 

lADOConnection.Close;
CLEAR(lADOConnection);

I tried to retrieve users from other Navision database, there should be just one user, then pop it as message for test.

Any help what could I do wrong here. Running this gives me next error message:
The call to member Item failed. ADODB.Parameters returned the following message:
Object can not be found from the set that corresponds to requested name or number.


I'm quite sure the database connection is working as it does not give error before the query.
K.S.

Comments

Sign In or Register to comment.