在经典ASP参数化SQL中使用变量

在经典ASP参数化SQL中使用变量,第1张

在经典ASP参数化SQL中使用变量

如果要避免重复,可以继续使用

DECLARE
变量并一次设置其值:

var sqlReview = "DECLARE @UserID AS Int = ?, @PgID AS Int = ?, @Rating AS TinyInt = ?;"sqlReview += "DELETe FROM PGrating WHERe (UserID = @UserID) AND (PgID = @PgID);"sqlReview += "INSERT INTO PGrating (InsertDate, PgID, UserID, Rating) VALUES (GETDATE(), @PgID, @UserID, @Rating);"

以上假设SQL Server 2008或更高版本。在较低版本上,您需要单独的一行来分配:

var sqlReview = "DECLARE @UserID AS Int, @PgID AS Int, @Rating AS TinyInt;"sqlReview += "SELECt @UserID = ?, @PgID = ?, @Rating = ?;"sqlReview += "DELETE FROM PGrating WHERe (UserID = @UserID) AND (PgID = @PgID);"sqlReview += "INSERT INTO PGrating (InsertDate, PgID, UserID, Rating) VALUES (GETDATE(), @PgID, @UserID, @Rating);"


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5620601.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存