手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Asp.Net编程>列表

Working with MS Access Stored Procedures in VB.NET Montaque(转贴)

来源:互联网 作者:西部数码 时间:2008-04-10
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
sConStr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data " _ & "Source=C:\Program Files\Microsoft " _ & "Office\Office10\Samples\Northwind.mdb" con = New OleDbConnection(sConStr) cmd.Connection = con cmd.CommandText = sSQL con.Open() cmd.ExecuteNonQuery() con.Close() End Sub End Module
 Working with MS Access Stored Procedures in VB.NET. Part 2 
by
David Wasserman, MCP


Article source code: msaccess_sp2.zip

Introduction

Welcome to part two of Access Stored Procedures. Part one described in detail how to create stored procedures in Access using ADO.NET and Visual Basic.NET. Part two will demonstrate how to utilize the stored procedures created in part one by assembling a Database Tier that can be modelled and used in your own applications. This article will describe in detail one implementation of a Database Tier for Visual Basic.NET.

The main purpose of the Database Tier is to provide a gateway to the database via a class module. This class module would act as the glue between the database and the application. There are two main advantages to using a data tier to access your database. You will have the ability to modify your underlying database technology (moving from MS Access to SQL Server for instance) without affecting your application in a major way. You will also be placing a control layer between your application and the database allowing you to ensure that all data is properly "cleansed". The Database Tier in .NET applications would most likely consist of a class module keeping in line with proper object-oriented coding conventions. Earlier versions of Visual Basic would employ a Standard Module to do the job.

Database Tier - Code

It''''s now time to roll up our sleeves and get dirty with some code. The first thing after adding an empty class declaration file is to pull in the proper .NET Framework libraries listed below.

Imports System.Data Imports System.Data.OleDb
"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program " _ & "Files\Microsoft Office\Office10\Samples\Northwind.mdb" Dim cmd As OleDbCommand = New OleDbCommand() Dim paramProductID As New OleDbParameter() cmd.Connection = con .ParameterName = "inProductID" .OleDbType = OleDbType.Integer .Size = 4

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!