Parameterised query with an ms access table

Parameterised query with an ms access table

am 01.02.2008 22:52:44 von John

Hi

When using sql server, I can use a sql like below in my data adapter to send
the sql a parameter value;

SELECT
FROM


WHERE Fieldx = @Para1

My question is, can I do something similar with an access db ie can I send a
parameter to a data adaptor sql which is connected to an ms access table? If
not is there another way to do this?

Thanks

Regards

Re: Parameterised query with an ms access table

am 01.02.2008 23:06:15 von sloan

SELECT KeyValueTable.Key, KeyValueTable.Value
FROM KeyValueTable
WHERE Key=pKey;



Create a query like the one above. I'm talking about in the program Access.


(I have a simple table, with 2 columns.... Key and Value, both strings of
50 chars)
(The table name is KeyValueTable)
(I put 3 rows in it... "1","One" ........"2","Two".........."3","Three")


Then your code in DotNet will look something like this:


xxxxxxx.AddInParameter ("pKey" , DbType.String , "2" );


Something like that. That is EnterpriseLibrary 3.1 code.. your code will
vary.



If you don't have access to the program Access...then wait for someone else
to chime in.

I'm not sure, since you didn't mention it.






"John" wrote in message
news:unLtEzRZIHA.1208@TK2MSFTNGP03.phx.gbl...
> Hi
>
> When using sql server, I can use a sql like below in my data adapter to
> send the sql a parameter value;
>
> SELECT
> FROM


> WHERE Fieldx = @Para1
>
> My question is, can I do something similar with an access db ie can I send
> a parameter to a data adaptor sql which is connected to an ms access
> table? If not is there another way to do this?
>
> Thanks
>
> Regards
>