asp执行存储过程,谁能看下哪里的问题吗
时间:2011-11-25
来源:互联网
VBScript code
dim id,title,content,content1,SQL ,connstr title = Request.QueryString("title") content = Request.QueryString("content") content1 = Request.QueryString("content1") set db = server.createObject("ADODB.Command") connstr= "driver={SQL Server};server=localhost;database=mydb;uid=sa;pwd=sa; " db.ActiveConnection=connstr db.commandtext="card" db.CommandType=4 db.Parameters.Append db.CreateParameter("@title",200,1,20 ,title) db.Parameters.Append db.CreateParameter("@content",200,1,20,content ) db.Parameters.Append db.CreateParameter("@content1",200,1,20,content1 ) db.Execute() db.close set db=nothing
作者: onefunnyday 发布时间: 2011-11-25
什么是存储过程?
存储过程是SQL server所提供的Tranact-SQL语言所编写的程序。
2. 如何建立存储过程?
Create Procedure EmployeeID_Orders
@EmployeeID as int
as
select * from orders
where employeeID=@EmployeeID
3. ASP中执行存储过程:
A. 编写sql语句:“execute 存储过程名 参数”,再通过connection.execute或recordset.open执行
strSql="execute employeeID_Orders 1"
Set objRstOrders=objCnnNorthwind.Execute(strSql)
B. 通command对象执行类型为acCmdStoredProc的命令
‘建立Command对象
Set objCmdNorthwind=Server.CreateObject("ADODB.Command")
‘设定命令的文本
objCmdNorthwind.CommandText="EmployeeID_Orders"
‘设定命令的类型
objCmdNorthwind.CommandType=adCmdStoredProc
‘设定命令对象使用的连接对象
Set objCmdNorthwind.ActiveConnection=objCnnNorthwind
‘建立参数对象
Set objParam=objCmdNorthwind.CreateParameter("@EmployeeID",adInteger,adParamInput)
‘把参数对象添加到命令对象的参数集中
objCmdNorthwind.Parameters.Append objParam
‘设定参数的值
objParam.Value=2
‘执行命令对象
Set objRstOrders=objCmdNorthwind.Execute()
‘销毁命令对象
Set objCmdNorthwind=Nothing
存储过程是SQL server所提供的Tranact-SQL语言所编写的程序。
2. 如何建立存储过程?
Create Procedure EmployeeID_Orders
@EmployeeID as int
as
select * from orders
where employeeID=@EmployeeID
3. ASP中执行存储过程:
A. 编写sql语句:“execute 存储过程名 参数”,再通过connection.execute或recordset.open执行
strSql="execute employeeID_Orders 1"
Set objRstOrders=objCnnNorthwind.Execute(strSql)
B. 通command对象执行类型为acCmdStoredProc的命令
‘建立Command对象
Set objCmdNorthwind=Server.CreateObject("ADODB.Command")
‘设定命令的文本
objCmdNorthwind.CommandText="EmployeeID_Orders"
‘设定命令的类型
objCmdNorthwind.CommandType=adCmdStoredProc
‘设定命令对象使用的连接对象
Set objCmdNorthwind.ActiveConnection=objCnnNorthwind
‘建立参数对象
Set objParam=objCmdNorthwind.CreateParameter("@EmployeeID",adInteger,adParamInput)
‘把参数对象添加到命令对象的参数集中
objCmdNorthwind.Parameters.Append objParam
‘设定参数的值
objParam.Value=2
‘执行命令对象
Set objRstOrders=objCmdNorthwind.Execute()
‘销毁命令对象
Set objCmdNorthwind=Nothing
作者: hefeng_aspnet 发布时间: 2011-11-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28