.net操作数据库
时间:2021-07-01 10:21:17
帮助过:27人阅读
/****** Object: StoredProcedure [dbo].[procLogin] Script Date: 08/14/2017 19:18:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[procLogin]
@userName varchar(50
),
@password varchar(50
)
AS
BEGIN
--
SET NOCOUNT ON added to prevent extra result sets from
--
interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements
for procedure here
SELECT * FROM [user] WHERE user_name = @userName AND password =
@password
END
调用
SqlConneteion conn = new SqlConnection("数据库信息");
SqlCommand command = new SqlCommand("存储过程名",conn)
command.CommandType = CommandType.StoreProcedure.
command.Parameter是.Add(new SqlParameter("@userName",userName));
SqlReader dr = command.executeReader()
一行一行读 读取不到返回false
得到宿处参数值
SqlParameter count = new SqlParameter("@count", 0);
count.Direction = System.Data.ParameterDirection.Output;
command.Parameters.Add(count);
int a= count.value();
.net操作数据库
标签:自动 ade null desc read extra var 数值 insert