I am trying to use ADO select query with parameters in Delphi 7 to
query data from SQLServer Mobile database.
I can successfully query the .sdf database file from Delphi, as long
as the query does not include any parameter statements.
However, if I issue the following command:
with ADOQuery1 do begin
...
SQL.Add('Select * from HISTORY where EVENTKEY =:NextEv');
Parameters.ParamByName('NextEv').Value := 5001;
Open;
...
end;
I get an EOleException Error: "The given type name was unrecognized.
[,,,,,]'
Similarly, using the ADO Insert query or the following ADO Command
produce the same error:
with ADOCommand1 do
begin
CommandText := 'Insert into HISTORY EVENTTYPE,EVENTKEY) VALUES
(7, :NextEv)';
CommandType := cmdText;
Parameters.ParamByName('NextEv').Value := 5005;
Execute;
end;
I have also tried to use the ParseSQL command, but that does not work
either:
ADOQuery1.Parameters.ParseSQL(ADOQuery1.SQL.Text, True);
I use the following ADOConnection ConnectionString in Delphi7:
Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\...
\test.sdf
Does this provider string require any other additional switches ?
It appears to work, as long as I don't try to use any parameters.
What needs to be done to pass the parameters to the SQLServer Mobile
database ?
The above code works without problems with Access database.
Thanks,
Mariusz
dbgrick - 17 Sep 2007 14:50 GMT
Try this instead:
SQL.Add('Select * from HISTORY where EVENTKEY =?');
Parameters.ParamByName('NextEv').Value := 5001;
Open;
Rick D.
Contractor
> I am trying to use ADO select query with parameters in Delphi 7 to
> query data from SQLServer Mobile database.
[quoted text clipped - 41 lines]
> Thanks,
> Mariusz
ErikEJ - 17 Sep 2007 17:06 GMT
You must preceede parameters with a @ (at-sign).
For a C# sample, see this:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2140307&SiteID=1

Signature
Erik Ejlskov Jensen, Mobile App Dev MCTS
Check out my SQL Compact blog at
http://erikej.blogspot.com
>I am trying to use ADO select query with parameters in Delphi 7 to
> query data from SQLServer Mobile database.
[quoted text clipped - 41 lines]
> Thanks,
> Mariusz
EliteHerd@gmail.com - 17 Sep 2007 23:48 GMT
> You must preceede parameters with a @ (at-sign).
> For a C# sample, see this:http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2140307&SiteID=1
> Erik Ejlskov Jensen, Mobile App Dev MCTS
Thank you for the suggestion but this does not work in Delphi. If I
precede parameters with @ instead of :
I get an error message: ADOQuery:Parameter 'NextEv' not found.
I have also tried the suggestion with using ? (see previous reply) but
that does not work either.
Again, I get an EOleException Error: "The given type name was
unrecognized.[,,,,,]'
Would you have any other suggestions how to overcome this major
issue ?
Without the ability to apply parameters in queries, I cannot use
sqlserver.ce.
Regards,
Mariusz
Erik Ejlskov - 18 Sep 2007 17:21 GMT
Could you post a code sample using @ please.

Signature
Erik Ejlskov Jensen
- see my SQL Compact blog at
http://erikej.blogspot.com
>> You must preceede parameters with a @ (at-sign).
>> For a C# sample, see
[quoted text clipped - 16 lines]
> Regards,
> Mariusz
TomiV - 08 Nov 2007 18:28 GMT
Hi Mariusz,
did you ever find a solution to this problem? I'm having the same problem
when using C++/ADO to access a compact edition database. Whenever I try to
use a parameter I get the DB_E_BADTYPENAME error which is the same error
that you mention in your post.
Thanks,
Tomi
>I am trying to use ADO select query with parameters in Delphi 7 to
> query data from SQLServer Mobile database.
[quoted text clipped - 41 lines]
> Thanks,
> Mariusz