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();
}
相关文档:
<%
function FSOFileDel(filename)
Dim objFSO,objCountFile,FiletempData
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile =objFSO.DeleteFile(Server.MapPath(filename),true)
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
En ......
ACCESS SQL语法参考
=================
一. 基础概念
可以使用的数据类型如下:
1. TEXT:文本型(指定长度时),备注型(不指定长度时);
2.
CHAR,NCHAR,VARCHAR,NVARCHAR:文本型,可以指定长度,否则默认值为255!
3. ......
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: ......
----比较复杂的数据库中一般会有位图数据(比如相片)。虽然这类“OLE对象”的插入、删除以及替换操作在ACCESS里容易实现,在VC中却显得复杂而且颇费周折。以下把作者用VC处理ACCESS数据库中的位图数据的体会简单叙述一下,以请教于大家。
----在CdaoRecordset派生类的对象中,VC自动为ACCESS的“OLE对象&r ......