Re: problem to SELECT using Microsoft Access (posted again, because of posting error)




Thank you for your respond. I play a lot and could not solve this problem. I
created parameter using the object inspector and the result is the same. I
got a exception that say:




Project Project1.exe raised exception class EOleException with message 'No
value given for one or more required parameters'.




I am sure I am applying the parameter to the query as required.



Let's consider code as this:




with ADOQuery1 do begin

Sql.Text:=

'select Column2 ' +

'from Table ' +

'where Column1 = '#39'THREAT_EVENTS'#39;

Open;

// Exception: Parameter Column1 has no default value;




//loop throug query result set:

while not eof do begin

........

Next;

end;

end;




The "Open" line raise the exception: "Parameter ThreatValue has no default
value"

There is no dynamic parameters at all but have an exception. I tried
unquoted string for the Column1 but got the same exception.

=========================================================


"Brian Bushay TeamB" <BBushay@xxxxxxxxx> wrote in message
news:m6mf62hj9ggdktanha00atfsubaqa6d15o@xxxxxxxxxx

I think you need to use AddParameter to create a parameter after you set
the SQL
property

I am apologizes if I am asking this question again and again. I browse
quickly the messages, but cannot find similar question:

I Want to make simple SELECT statement against Microsoft Access table.
Everything is very simple, the table has two column and I want to do:

SELECT Colimn2
FROM Table
WHERE Column1 = 'XYZ'

In my Delphi source code I have TADOConnection and TADOQuery component.
Next
is my source code:

procedure TForm1.Button1Click(Sender: TObject);
var
sDB: string;
begin
sDB := (ExtractFilePath(Application.ExeName) + 'Test.mdb');
adoConn.ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;' +
'Data Source=' + sDB + ';' +
'Mode=Share Deny None;' +
'Extended Properties="";' +
'Persist Security Info=False;' +
'Jet OLEDB:System database="";' +
'Jet OLEDB:Registry Path="";' +
'Jet OLEDB:Engine Type=5;' +
'Jet OLEDB:Database Locking Mode=1;' +
'Jet OLEDB:Global Partial Bulk Ops=2;' +
'Jet OLEDB:Global Bulk Transactions=1;' +
'Jet OLEDB:New Database Password="";' +
'Jet OLEDB:Create System Database=True;' +
'Jet OLEDB:Encrypt Database=False;' +
'Jet OLEDB:Don''t Copy Locale on Compact=False;' +
'Jet OLEDB:Compact Without Replica Repair=False;' +
'Jet OLEDB:SFP=False';
adoConn.Open;

with ADOQuery1 do begin
Sql.Text:=
' SELECT Column2' +
' FROM Table' +
' where Column1 = :param1';

Parameters[0].DataType:= ftString;
Parameters[0].Direction:= pdInput;
Parameters.ParamByName('param1').Value:= 'THREAT_EVENTS';

Open;
end;
end.

On open ADOQuery1 I got an exception:

Project Project1.exe raised exception class EOleException with message 'No
value given for one or more required parameters'.

I thing something is wrong in my source code. I know Microsoft Access has
very odd rules.
I will appreciate if someone could help me.

--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx


.