ht use MS Access like a stored procedure?

  • Thread starter Thread starter Rigid Kitten
  • Start date Start date
R

Rigid Kitten

I cannot figure out how to:

1. call an Access query from C# and consume the recordset, where the query
uses a user defined function. for example

select rowid, GetBreedOfCat([rowid]) from tblCats;



2. call an Access function from C# and consume the returned value. For
example, how to consume the returned recordset:
Public function getAllcats() as recordset
end function


Thank you for your help,

John
 
In the same way as with any other COM component: you must use automation and
COM Interoperability to achieve things like that by opening an Access
application object and making your call from this object.

An Access database is split into two entity: the Database part, with the JET
driver and the VBA/GUI part. When you open an access database with the JET
ADO.NET driver, you don't have access to the VBA/GUI part. If you want to
have access to a VBA functionf, you must first open the Acces application as
a COM object and ask it to make the required call to the JET driver on your
behalf.

Obviously, unless you already know your way in and out of Access automation,
this is probably not worth the energy to try it.

S. L.
 
¤ I cannot figure out how to:
¤
¤ 1. call an Access query from C# and consume the recordset, where the query
¤ uses a user defined function. for example
¤
¤ select rowid, GetBreedOfCat([rowid]) from tblCats;
¤

User defined (VBA) functions are not supported through Jet OLEDB or ODBC. They're only supported
when running under Access. Only the sandbox functions are supported:

http://support.microsoft.com/default.aspx?scid=kb;en-us;294698

¤
¤
¤ 2. call an Access function from C# and consume the returned value. For
¤ example, how to consume the returned recordset:
¤ Public function getAllcats() as recordset
¤ end function

This isn't supported unless you use Access automation as Sylvain pointed out.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top