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();
}
相关文档:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=Microsoft.Jet.OLEDB.4.0;Password=ypbwkfyjhyhgzj;User ID=morningstar;Data Source=C:\Program Files\Kingdee\KIS\BZB\北极星.AIS;Persist Security Info=True;Jet OLEDB:System database=C:\Program Files\Kingdee\KIS\BZB\system.mda
......
asp.net的错误--Failed to access IIS metabase 收藏
Server Error in '/sdxx' Application.
--------------------------------------------------------------------------------
Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the current web ......
原因:IIS没有注册,我是原有系统的IIS删了,造成运行IIS中的应用程序出现这种错误!
解决办法:
在CMD中进入目录C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727,运行aspnet_regiis
1、aspnet_regiis -ga administrator(administrator为当前用户)
2、aspnet_regiis -i (注册IIS)
3、iisreset /noforce (重启IIS)
......
#include "iostream.h"
#include "stdio.h"
#import "C:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
int main(int argc, char* argv[])
{
::CoInitialize(NULL);
_ConnectionPtr m_pConnection;
m_pConnection.CreateInstance("ADODB.Connection");
tr ......