0

我正在升级我的应用程序以使用存储过程,而不是像现在这样使用动态 SQL。我想做的是调用一些过程,例如 setUser(id),然后在当前连接期间将该 ID 结转。我有一个 UserVariables 表,它存储与当前用户相关的重要数据(我没有使用会话来存储这些数据,因为会话只持续这么长时间;这样用户数据会在登录之间保持不变)。我想选择数据,例如他们当前正在查看的客户端的 ID,而不必将用户 ID 传递到每个存储过程。如果你愿意,可以称之为懒惰!

我已经搜索了很多,并查看了各种文章,但它们都是关于全局变量(我们无法更改)或无关的东西。

基本上我想要做的是在页面加载开始时设置用户 ID(有时甚至可以将其移动到 session_start 方法中),然后在所有后续存储过程调用或查询期间访问此变量。

编辑:我所追求的就像您在asp页面的开头设置一个变量(我的应用程序是用好的ol'经典asp编写的)然后您在整个页面和任何包含中使用它。如果您愿意,可以考虑表示连接的 asp 页面和表示存储过程的包含。

4

1 回答 1

0

I have found a suitable alternative to setting connection-specific variables. I have a function which takes the sproc name, an array of parameter names, an array of parameter values and a variable to return (i.e. a byref variable). I have modified this function so that, when the parameters are refreshed, it checks for a userid parameter and sets it automatically if it exists. It then returns the 'retval' parameter if it exists, otherwise sets the return variable to myCmd.execute.

于 2012-09-15T22:04:08.597 回答