requirements, then deciding if all items are in place for ie. a production
under certain conditions. if so, the class return TRUE.
My question is. Can I implement a similar "class" in sql, so sql is doing
Post by William KYou may execute SQL statements with using the CCADO* and DSO* classes. The
command can be both a Transact-SQL statement, or you are allowed to call
stored procedures with parameters. Here is an easy example, which works both
static void ExecSQLStatement(Args _args)
{
#CCADO
CCADOConnection connection;
CCADOCommand command;
CCADORecordSet recordSet;
CCADOFields fields;
str provider = "yourdatabaseservername";
str database = "youraxaptadatabasename";
str connectionString = strfmt("Provider=sqloledb;Data
Source=%1;Initial Catalog=%2;Trusted_Connection=yes;", provider, database);
str statement = "SELECT * FROM SYSUSERINFO";
;
connection = new CCADOConnection();
connection.open(connectionString, #adConnectUnspecified);
command = new CCADOCommand();
command.activeConnection(connection);
command.commandText(statement);
recordSet = command.execute();
while (!recordSet.EOF())
{
fields = recordSet.fields();
info(strfmt("%1", fields.itemName("id").value()));
recordSet.moveNext();
}
connection.close();
connection = null;
}
Please note that with trusted connection, AX tries to use your user account
to log in to the SQL server, and you must have read access to the
database/table. You may construct your own connection strings and add
userid/password for example, check the webpage
http://www.connectionstrings.com/
Also do not forget that if you are using tables saved per company, you have
to provide the "WHERE TABLE.DATAAREAID = 'dat'" clause, providing that which
company accounts you would like to use.
Post by Robert BWilliam,
This is the most information I have found in one place on the use of
CCADO. There is just one more issue that I need to address and that is how
to call a stored procedure with an input parameter and an output parameter.
Do you know where I can find a command reference on the CCADO class? One
that is more than TBD?
Thanks
Robert
Post by unknownSadly there are no references out there regarding this topic, I have used
MSDN on how the ADO works, and I extended the CCADO classes with the methods
they have described.
I have created a simple stored procedure on my DYNAX09_DEV database to
USE [DYNAX09_DEV]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[GetSalesName]
@SalesId nvarchar(20)
AS
BEGIN
SELECT SalesName
FROM dbo.SalesTable
END
GO
Then you just call the stored procedure as a simple Transact-SQL command,
static void ExecSQLStatement(Args _args)
{
#CCADO
CCADOConnection connection;
CCADOCommand command;
CCADORecordSet recordSet;
CCADOFields fields;
str provider = "mycomputer";
str database = "DYNAX09_DEV";
str connectionString = strfmt("Provider=sqloledb;Data
Source=%1;Initial Catalog=%2;Trusted_Connection=yes;", provider, database);
str statement = "EXEC GetSalesName '00017_036'";
;
connection = new CCADOConnection();
connection.open(connectionString, #adConnectUnspecified);
command = new CCADOCommand();
command.activeConnection(connection);
command.commandText(statement);
recordSet = command.execute();
while (!recordSet.EOF())
{
fields = recordSet.fields();
info(strfmt("%1", fields.itemIdx(0).value()));
recordSet.moveNext();
}
connection.close();
connection = null;
}
And sorry if my answer answers too late, I was on holiday ;-]
Regards,
William
Submitted via EggHeadCafe
Microsoft Silverlight For Beginners
http://www.eggheadcafe.com/training-topic-area/Microsoft-Silverlight/10/Silverlight.aspx