我使用存储过程来插入、更新和删除记录,并使用 LINQ 来执行或调用这些过程。点击提交按钮后,更新程序已执行,但表中没有任何变化!如果我传递像“Jack”这样的值而不是 fname_txt.text,它会起作用并被更新。我不知道文本框对象和引号中的值有什么区别?!这是代码:
protected void submit_Click(object sender, EventArgs e)
{
try
{
ZobLinqDataContext db = new ZobLinqDataContext();
string pasword = CryptorEngine.Encrypt(pass_txt.Text, true);
long uid = Convert.ToInt64(Request["uid"]);
db.pUpZDBUser(uid,
uname_txt.Text,
pasword,
fname_txt.Text.Trim(),
lname_txt.Text.Trim(),
modir.Checked,
voting.Checked,
Convert.ToInt32(Zarib_txt.Text),
false
);
db.SubmitChanges();
Response.Write(uname_txt);
}
finally
{
Session["sub"] = "1";
}
}
这是更新过程:
USE [ZOBDB]
GO
/****** Object: StoredProcedure [dbo].[pUpZDBUser] Script Date: 04/11/2012 15:17:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[pUpZDBUser]
@UID bigint,
@Uname nvarchar(100),
@Pass nvarchar(100),
@fname nvarchar(50),
@lname nvarchar(50),
@KU bit,
@KV bit,
@ZribV int,
@del bit
As
BEGIN TRANSACTION UpUser
Set NOCOUNT ON
UPDATE Users SET
Uname=@Uname,
Pass=@Pass,
fname=@fname,
lname=@lname,
KU=@KU,
KV=@KV,
ZribV=@ZribV,
del=@del
where (UID=@UID)
--RollBack if Err
IF @@ERROR != 0 and @@ROWCOUNT != 1
BEGIN
declare @msg nvarchar(30)
set @msg = ' error '+@Uname
ROLLBACK
RAISERROR(@msg,16,1)
RETURN
END
COMMIT TRANSACTION UpUser
RETURN