command.execute 存储过程应用
发布网友
发布时间:2022-05-01 18:32
我来回答
共3个回答
懂视网
时间:2022-05-03 04:31
NOT EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N‘[dbo].[CreateAuthor]‘) AND type in (N‘P‘, N‘PC‘))
BEGIN
EXEC dbo.sp_executesql @statement = N‘
CREATE PROCEDURE [dbo].[CreateAuthor]
@FirstName Varchar(50),
@LastName Varchar(50),
@Address Varchar(100)
AS
INSERT INTO dbo.Authors(
[FirstName],
[LastName],
[Address]
)
VALUES (@FirstName, @LastName, @Address)
‘
using (var context = new BookStore())
{
int affectedRows = context.Database.ExecuteSqlCommand("CreateAuthor @p0, @p1, @p2",
parameters: new[]
{
"Mark",
"Cuban",
"23 Tsawassen Blvd."
});
}
9.用ExecuteSqlCommand执行存储过程
标签:cts exist 执行存储过程 te pro sys data span object_id fir
热心网友
时间:2022-05-03 01:39
定义存储过程
CREATE PROCEDURE sp_CountUsers AS
Return (select count (*) from users)
______________________________________________________________________
asp页面
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<%
Dim conn,cmd,param
Set conn = server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={SQL Server};Server=.;Database=UserDB"
conn.Open
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "sp_CountUsers"
cmd.CommandType = adCmdStoredProc ’错误提示为此行
Set param = cmd.CreateParameter("ReCount",adInteger,adParamReturnValue)
cmd.Parameters.Append param
cmd.Execute
Response.write "用户表中的总纪录数为:" & cmd.Parameters("ReCount")
Set cmd = Nothing
conn.Close
Set conn = Nothing
%>
</BODY>
</HTML>
——————————————————————————————————
错误提示
错误类型:
ADODB.Command (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
问题补充:谢谢 我按照您的建议修改后还是不能正常运行,有空请再帮我看看。asp初学,上边的例子我是照书上的例子打的,这本书快把我搞疯了....
热心网友
时间:2022-05-03 02:57
command.execute 和 connection.execute 有什么区别??