Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ASPX SQL语句中访问C#变量值_C#_Asp.net_Sql_Sql Server - Fatal编程技术网

在ASPX SQL语句中访问C#变量值

在ASPX SQL语句中访问C#变量值,c#,asp.net,sql,sql-server,C#,Asp.net,Sql,Sql Server,我有一个aspxSqlDataSource,用于将值插入表中以跟踪请求。我使用LDAP对用户进行身份验证,并希望在我的请求表的SubmittedBy列中自动插入正确的用户 用户ID是通过一个C#变量userId访问的,我在页面加载期间收集该变量 然而,如何在我的UpdateCommand中包含该值,这让我陷入了困境 目前我有以下几点: UpdateCommand="INSERT INTO [EditRequest] ([AppId] , [SubmittedBy] , [SourceContro

我有一个aspx
SqlDataSource
,用于将值插入表中以跟踪请求。我使用LDAP对用户进行身份验证,并希望在我的请求表的
SubmittedBy
列中自动插入正确的用户

用户ID是通过一个C#变量
userId
访问的,我在页面加载期间收集该变量

然而,如何在我的
UpdateCommand
中包含该值,这让我陷入了困境

目前我有以下几点:

UpdateCommand="INSERT INTO [EditRequest] ([AppId]
, [SubmittedBy]
, [SourceControlId]
, [RepoLocation], [MainBranch], [isBBLITE], [ResourceDir], [scriptLocation]
, [BarFileLocation], [R9Branch], [auditR9], [R10Branch], [audit10_1], [R10_2Branch]
, [audit10_2], [DateSubmitted], [ExpectedDate]) 

VALUES (@ApplicationId
, **<%=userId%>**
, @SourceControlId
, @RepoLocation, @MainBranch, @isBBLITE, @ResourceDir
, @scriptLocation, @BarFileLocation, @R9Branch, @auditR9, @R10Branch, @audit10_1
, @R10_2Branch, @audit10_2, GETDATE(), GETDATE()+5)">
UpdateCommand=“插入到[EditRequest]([AppId]
,[提交人]
,[SourceControlId]
,[RepoLocation],[MainBranch],[isBBLITE],[ResourceDir],[scriptLocation]
,[BarFileLocation],[R9Branch],[auditR9],[R10Branch],[audit10_1],[R10_2 Branch]
,[audit10_2],[DateSubmitted],[ExpectedDate])
值(@ApplicationId)
, ****
,@SourceControlId
、@RepoLocation、@MainBranch、@isBBLITE、@ResourceDir
、@scriptLocation、@BarFileLocation、@R9Branch、@auditR9、@R10Branch、@audit10_1
,@R10_2Branch,@audit10_2,GETDATE(),GETDATE()+5)”>
但在运行时,它会抱怨找不到
请尝试以下操作

VALUES (@ApplicationId , +"<%=userId%>.val()"+ , @SourceControlId
值(@ApplicationId,+”.val()“+,@SourceControlId

或者您可以在这种情况下使用
Session
变量。

我建议使用查询参数。您从哪里获取其他参数?为什么不从同一个位置获取用户ID?