易截截图软件、单文件、免安装、纯绿色、仅160KB

ACCESS里面创建带参数的存储过程

需要注意的是page_load里面的创建存储过程只能执行一次,如果第二次还要创建同名的话会提示错误信息“存储过程已经存在。”,其实加个判断就行了。懒得加了,只是用来试验一下。
调试环境 ASP.NET 2.0(编译工具VS2008),代码C#,access版本2003
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection oledb = new OleDbConnection();
oledb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\asp99cms.mdb;Jet OLEDB:Database Password=";
oledb.Open();
if (oledb.State == ConnectionState.Open)
{
string str = "Create proc pr_test(@uid int) As select * from Download where [ID]=@uid";
OleDbCommand olecom = new OleDbCommand();
olecom.CommandText = str;
olecom.Connection = oledb;
olecom.ExecuteNonQuery();
oledb.Dispose();
}
oledb.Close();
oledb.Dispose();
}
protected void Button2_Click(object sender, EventArgs e)
{
OleDbConnection oledb = new OleDbConnection();
oledb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\asp99cms.mdb;Jet OLEDB:Database Password=";
oledb.Open();
if (oledb.State == ConnectionState.Open)
{
OleDbCommand olecom = new OleDbCommand("pr_test",oledb);
olecom.CommandType = CommandType.StoredProcedure;
olecom.Parameters.Add(new OleDbParameter("@uid",OleDbType.Integer)).Value=TextBox1.Text;
olecom.Connection = oledb;
OleDbDataReader oledr;
oledr=olecom.ExecuteReader();
oledr.Read();
if (oledr.HasRows)
{
Response.Write("存储过程执行成功");
}
oledr.Close();
oledr.Dispose();
oledb.Dispose();
}
oledb.Close();
oledb.Dispose();
}


相关文档:

用ASP.NET/C#连接Access和SQL Server数据库

连接Access
首先看一个例子代码片断:
程序代码:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:\BegASPNET\Northwind.mdb" ......

Access Web 数据库和 Access 展示

Access 项目管理团队的 Clint 在此向 Office 工程博客的读者表示问候。通过与第 9 频道合作,Access 团队即将推出一个名为 Access 展示的新展示。其主要人物包括 Ryan McMinn、我本人以及团队的其他人员。我们将深入探讨 Access 2010 和 Access Services 中的新增功能,并分享来自社区的反馈。
此外,最近在 SharePoint D ......

Failed to access IIS metabase

Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Hosting.HostingEnvironmentException: ......

VB连接ACCESS数据库精简版

Option Explicit
Private Sub Form_Load()
'工程->引用->选中Microsoft ActiveX Data Objects 2.8 Library
Dim shujukulianjie As New ADODB.Connection
Dim jiluji As New ADODB.Recordset
'连接数据库的代码段
shujukulianjie.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Sour ......

SQLITE与ACCESS性能简单测试对比

这段时间在做CMS(客户管理系统,不是内容管理)的访问管理功能,要求实现对服务提供设备,客户端,计费,权限认证等信息的存储统计,远程管理。要求系统发布要方便,远程管理软件要跑在WIN平台。考虑到系统规模,客户要求,最后选择了WIN+ACCESS的方案,而最近又发现一个免费的SQLITE,而且可能在以后的手持设备上用,花点 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号