【发布时间】:2014-06-22 23:49:17
【问题描述】:
我有一个禁止重复电子邮件地址的存储过程。
create PROCEDURE [dbo].[CheckEmail1]
(@email nvarchar(50))
AS
BEGIN
DECLARE @ERORR NVARCHAR(50)
SET NOCOUNT ON;
if not exists (SELECT C.Email FROM Customer C WHERE Email=@email)
BEGIN
INSERT INTO Customer (Email) VALUES (@email)
END
ELSE
BEGIN
declare @errormessage nvarchar(50) = 'This Email Address is Exists'
RAISERROR (@errormessage,11,1)
END
END
我想在 asp.net 文本框中使用这个存储过程?我怎样才能做到这一点? 这是我的 C# 代码:
try
{
var db = new DataClassesDataContext();
db.CheckEmail1(TextBox1.Text);
db.SubmitChanges();
}
catch (Exception ex)
{
Label6.Text = ex.Message;
}
【问题讨论】:
-
你有什么问题?
-
希望这个链接对你有帮助ezineasp.net/post/…
-
我的问题是我无法使用 up 过程插入 sql
标签: c# asp.net sql linq stored-procedures