can make stored procedure or function in Access 2003?

后端 未结 2 1801
面向向阳花
面向向阳花 2021-01-27 06:53

In Access 2003, can we create stored procedure or function?

2条回答
  •  Happy的楠姐
    2021-01-27 07:32

    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

提交回复
热议问题