Conclusion
Hopefully, this article has provided some guidance in a nearly undocumented area of Access and Jet not yet explored by most. For more information on how the ADO.NET code works in the CreateStoredProc subroutine, see Getting Started with ADO.NET by Gurneet Singh. The following is a complete listing of all code presented in this article:
Imports System.Data Imports System.Data.OleDb Module CreateSP Sub Main() ProductsProcs() End Sub '''' Products Stored Procs to be added to the db. Sub ProductsProcs() Dim sSQL As String '''' procProductsList - Retrieves entire table sSQL = "CREATE PROC procProductsList AS SELECT * FROM Products;" CreateStoredProc(sSQL) '''' procProductsDeleteItem - Returns the details (one record) from the '''' JobTitle table sSQL = "CREATE PROC procProductsDeleteItem(@ProductID LONG) AS " _ & "DELETE FROM Products WHERE ProductID = @ProductID;" CreateStoredProc(sSQL) '''' procProductsAddItem - Add one record to the JobTitle table sSQL = "CREATE PROC procProductsAddItem(inProductName VARCHAR(40), " _ & "inSupplierID LONG, inCategoryID LONG) AS INSERT INTO " _ & "Products (ProductName, SupplierID, CategoryID) Values " _ & "(inProductName, inSupplierID, CategoryID);" CreateStoredProc(sSQL) '''' procProductsUpdateItem - Update one record on the JobTitle table sSQL = "CREATE PROC procProductsUpdateItem(inProductID LONG, " _ & "inProductName VARCHAR(40)) AS UPDATE Products SET " _ & "ProductName = inProductName WHERE ProductID = inProductID;" CreateStoredProc(sSQL) End Sub '''' Execute the creation of Stored Procedures Sub CreateStoredProc(ByVal sSQL As String) Dim con As OleDbConnection Dim cmd As OleDbCommand = New OleDbCommand() Dim da As OleDbDataAdapter '''' Change Data Source to the location of Northwind.mdb on your local '''' system. Dim
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




