开发者

can make stored procedure or function in Access 2003?

开发者 https://www.devze.com 2023-02-25 12:43 出处:网络
In Access 2003, 开发者_开发百科can we create stored procedure or function?For Access 2003, the answer is no.

In Access 2003, 开发者_开发百科can we create stored procedure or function?


For Access 2003, the answer is no.

Access 2010 does have table triggers and store procedures. These are true engine level routines that run as a result of row updates. So forms or VBA recordset code or sql updates that cause a row modify will cause the store procedure and table level code to run. In fact, even external connections via ODBC from vb.net, or even VB6 will cause these store procedures to run.

However prior to Access 2010 you do not have store procedures if you use the default database engine. However, you can choose a different data engine then JET for your Access applications and when you do this then yes you can have store procedures, but you have to use the tools that come with whatever data base engine you have chosen to use with Access. So, keep in mind that just like when you build a web site, you then can go out and choose what database engine you use. The same goes for ms-access and you are free to go out and choose a database engine that has store procedures to be used with Access.

As noted, the exception to this is that Access 2010 does have table level triggers and store procedures now.


Not "Stored Procedures" as such. You can create saved queries and call those from Access in the same way as stored procs form Sql Server. The limitations that the saved queries have are that you cannot use control of flow code (such as If Else or Case When) and you can only save one command at a time.

The simplest way to create saved queries is to open up Access, go the Query tab and create a new query in Design View. Close the Show Tables dialogue box and switch to SQL View. Using the example above, type in the first part of the SQL clause:

    INSERT INTO Addresses ( Organisationname, AddressLine1, AddressLine2,
    AddressLine3, City, StateCounty, CountryID, PostCodeZip, SwitchboardNo,
    FaxNo, Email, Website, RecordStatus, LastUpdated, LastUpdateBy )
    Values

Now open the brackets and create the parameter place holders. These are always in square brackets ( [ ] ), which tells Access to expect a value as a parameter. You can put anything you like within the square brackets. [p1], [p2], [p3] etc are my choice, so the final query will look like this:

    INSERT INTO Addresses ( Organisationname, AddressLine1, AddressLine2,
    AddressLine3, City, StateCounty,CountryID, PostCodeZip, SwitchboardNo, FaxNo, 
    Email, Website, RecordStatus, LastUpdated, LastUpdateBy ) Values ([p1],[p2],[p3],
    [p4],[p5],[p6],[p7],[p8],[p9],[p10],[p11],[p12], [p13],[p14],[p15]);

If you Run the query, Access will prompt you for input for each field. Enter data against each field to test that the query is working. As for debugging, you've just done it. Save the query as something meaningful. This one is saved as qUpdateAddresses. As you save it, you may notice that Access automatically detects that this is an Append Query. Once you have verified that it works, close the database.

to run it from ASP.NET, look at this article, paying attention to the bit towards the end that's headed "Saved Queries": http://www.mikesdotnetting.com/Article.aspx?ArticleID=26

0

精彩评论

暂无评论...
验证码 换一张
取 消