Showing posts with label delphi. Show all posts
Showing posts with label delphi. Show all posts

Friday, March 30, 2012

MS SQL This feature has not been implemented yet

Hi, I'm a Delphi programmer, and using an ADO Dataset, I'm trying to select some data from a database. However, when I set it up using parameters, I get an error in Delphi that this Feature has not been implemented yet. Can anyone help me configure the MS SQL database, so I can run SQL queries with parameters?which version of Delphi and SQL are you using. I use D6 with SQL 2k and have no problems (well, almost none) using an ADO dataset. What is your sql statement and how did you define your parameters?|||I am using Delphi version 7 and MS SQL 2000. Here is the Commandtext from my ADODataset:

select count(*) from CallDetail calldetail where i3timestampgmt between :BegTime and :EndTime and initiateddate between :BegTime2 and :EndTime2 and LocalUserId = :User

If I plug in actual values in the SQL instead of parameters, the script runs just fine. Then here is how I defined the parameters:

dmReports.ADODataSet1.Parameters.ParamByName('BegT ime').Value := FormatDateTime('mm/dd/yyyy hh:nn', BegDate);
dmReports.ADODataSet1.Parameters.ParamByName('EndT ime').Value := FormatDateTime('mm/dd/yyyy hh:nn', EndDate + 1);
dmReports.ADODataSet1.Parameters.ParamByName('BegT ime2').Value := FormatDateTime('mm/dd/yyyy hh:nn', BegDate);
dmReports.ADODataSet1.Parameters.ParamByName('EndT ime2').Value := FormatDateTime('mm/dd/yyyy hh:nn', EndDate + 1);
dmReports.ADODataSet1.Parameters.ParamByName('User ').Value := workgroupmembers[i];
dmReports.ADODataSet1.Active := True;
ShowMessage(dmReports.ADODataSet1COLUMN1.AsString) ;

At the beginning of the procedure I defined them like this:

BegTime, EndTime, BegTime2, EndTime2, User: Variant;|||your declarations seem ok at first sight. My guess would be to change the parameter named 'user' to another name because this is keyword used by sql server.|||I tried changing User to Operator, and it is still giving the exact same error. I am guessing that the MS SQL is not configured correctly, and maybe under the current configuration it can't handle parameters.|||I don't see how it could be configured to not accept parametrized queries from a client application. What is the exact error message you get? If you click on the parameters property in the object inspector, does it display all your parameters correctly?|||In the object inspector all the parameters are displayed correctly. Here is the message that I receive

--------
Debugger Exception Notification
--------
Project report.exe raised exception class EOleException with message '[Microsoft][ODBC SQL Server Driver]Optional feature not implemented'. Process stopped. Use Step or Run to continue.
--------
OK Help
--------|||There is nothing to configure in sql server to allow it to accept queries.
Depends on what is being sent to the server by the app as to whether it will work.
Try using the sql server profiler to trace what is being sent.

Check the delphi documentation and the provider you are using as the error is comming probably comming from one of these|||see http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q214/4/59.asp&NoWebContent=1 for more info.|||I just ran the SQL Server Profiler from the Server, and that query is not even showing up there. I know that it connects however, because when I run a query without the parameters, it does show up.

Also, I beleive that the Microsoft website is talking about Visual Basic, instead of Delphi.|||Thanks for all your help jora and nigellrivett. I couldn't get it working, so I decided that instead of using parameters, I'd set the commandtext property directly with the right values in a procedure in Delphi.sql

Monday, February 20, 2012

Ms Sql

Can anybody help me about this??

I'm new from using the MS SQL and i need a function/procedure/trigger......

there is this function from Delphi (FormatCurr) that I used to create a new record id
...FormatCurr('0000000000',Tqry.FieldByName('Budg etNo').AsInteger+1........

but then i want to make the same thing in MS SQL but i dont know what function to used so instead i did this dumb coding thing

CREATE PROCEDURE budget_newrecord
AS
DECLARE @.budgetno_old int,@.budgetno_new CHAR(10), @.budget_no int
SELECT TOP 1 @.budgetno_old = cast(budgetno as int)from budgetinfo order by budgetno desc

SET @.budget_no = @.budgetno_old + 1

IF @.budget_no <= 0
SET @.budgetno_new = '0000000001'
ELSE IF @.budget_no < 10
SET @.budgetno_new = '000000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100
SET @.budgetno_new = '00000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 1000
SET @.budgetno_new = '0000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 10000
SET @.budgetno_new = '000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100000
SET @.budgetno_new = '00000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 1000000
SET @.budgetno_new = '0000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 10000000
SET @.budgetno_new = '000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100000000
SET @.budgetno_new = '00' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100000000
SET @.budgetno_new = '0' + cast(@.budget_no as char)
ELSE IF @.budget_no < 1000000000
SET @.budgetno_new = cast(@.budget_no as char)

PRINT @.budgetno_new
RETURN @.budgetno_new
GO

Quote:

Originally Posted by clear1140

Can anybody help me about this??

I'm new from using the MS SQL and i need a function/procedure/trigger......

there is this function from Delphi (FormatCurr) that I used to create a new record id
...FormatCurr('0000000000',Tqry.FieldByName('Budg etNo').AsInteger+1........

but then i want to make the same thing in MS SQL but i dont know what function to used so instead i did this dumb coding thing

CREATE PROCEDURE budget_newrecord
AS
DECLARE @.budgetno_old int,@.budgetno_new CHAR(10), @.budget_no int
SELECT TOP 1 @.budgetno_old = cast(budgetno as int)from budgetinfo order by budgetno desc

SET @.budget_no = @.budgetno_old + 1

IF @.budget_no <= 0
SET @.budgetno_new = '0000000001'
ELSE IF @.budget_no < 10
SET @.budgetno_new = '000000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100
SET @.budgetno_new = '00000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 1000
SET @.budgetno_new = '0000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 10000
SET @.budgetno_new = '000000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100000
SET @.budgetno_new = '00000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 1000000
SET @.budgetno_new = '0000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 10000000
SET @.budgetno_new = '000' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100000000
SET @.budgetno_new = '00' + cast(@.budget_no as char)
ELSE IF @.budget_no < 100000000
SET @.budgetno_new = '0' + cast(@.budget_no as char)
ELSE IF @.budget_no < 1000000000
SET @.budgetno_new = cast(@.budget_no as char)

PRINT @.budgetno_new
RETURN @.budgetno_new
GO


try:

@.budgetno_new = right('000000000'+ rtrim(ltrim(cast(@.budget_no as varchar(12))),9)|||

Quote:

Originally Posted by ck9663

try:

@.budgetno_new = right('000000000'+ rtrim(ltrim(cast(@.budget_no as varchar(12))),9)


Hey ck9663....... thanks a lot...... it really works.......... thank you!!!!!!!!!!!