Re: Parameter object is improperly defined. Access vs MSSQL



MS Access and MS SQL implementations for DML are quite different. For MS SQL
you should use something like this:
declare @SurveyID GUID, @QuestionID LONG, @SessionID LONG
set @SurveyID = :SurveyID
set @QuestionID = :QuestionID
set @SessionID = :SessionID
SELECT NULL AS Extended, Count(*) AS IntValue, NULL AS AValue
FROM Answers AS A
WHERE (A.SurveyID= @SurveyID ) AND (A.QuestionID = @QuestionID ) AND
(A.Extended <> 0)
UNION ALL
SELECT A.Extended, F.IntValue, F.TextValue as AValue
FROM Answers AS A INNER JOIN FilledSurveys AS F ON (A.SurveyID=F.SurveyID
AND A.QuestionID=F.QuestionID AND A.AnswerID=F.IntValue AND F.SessionID =
@SessionID )
WHERE (A.SurveyID= @SurveyID ) AND (A.QuestionID = @QuestionID )


If you need generic solution for this specific case you use procedure like
this for parameters assignment:



Procedure AssignParameter(ADataSet : TADODataSet; AName : string; const
AValue : Variant);

Var

I : Integer;

Begin

For I := 0 to ADataSet.Parameters.Count - 1 do with
ADataSet.Parameters[i] do begin

If CompareText(Name, AName) = 0 then begin

Value := AValue;

End;

End;

End;


However you should be aware that there are a lot of others differences
between MS SQL Server and Access.



Regards,

Vitali


.



Relevant Pages

  • Re: how to sum a text field with commas
    ... "BY DEFINITION a column has scalar values, this is not a valid value in SQL" ... Holding "1,2,3" in a column has nothing to do with DDL, DML, DCL, and transaction control. ... IT has everything to do with database design 1nf, ... I find that most one-shot jobs have the data I want on a ...
    (microsoft.public.sqlserver.programming)
  • Re: Early and late binding.
    ... > With a SQL DBMSs one is forced to separate DDL from DML which may or may ... To relate your last point back to binding, ... where the model is static between DDL transactions. ... not coded as DML, but as something else. ...
    (comp.databases.theory)
  • Re: Separation of DDL and DML - was: Early and late binding.
    ... >> With a SQL DBMSs one is forced to separate DDL from DML which may or may ... In what respects does SQL enforce DDL separate ... > from DML? ...
    (comp.databases.theory)
  • Re: how to sum a text field with commas
    ... Actually it is DDL, DML, DCL and transaction control. ... fail to create integrated systems. ... I find that most one-shot jobs have the data I want on a ...
    (microsoft.public.sqlserver.programming)
  • Re: Conditionally Adding SQL
    ... Everything else is not SQL, just proprietary stuff that should be done in some other language anyway. ... (Aside from the fact that the DDL and DML may not always measure up to the pure language of SQL.) ... As to how far you cna get in real world solving real problem with ...
    (microsoft.public.sqlserver.programming)