0

我有一个下拉列表,其中的值是从表的两列连接起来的,现在我将使用该下拉列表的值作为另一个存储过程的参数,这可能吗?我将如何做到这一点?

这是我的代码

CREATE PROCEDURE [dbo].[Reassign]
   @recordumber int
   @employeeName
AS
BEGIN
    UPDATE QR
    SET QR.QAMemberID = @QAMemberID
    FROM Roster AS QR
    INNER JOIN TeamMaster S TM 
       ON QR.QAMemberID = TM.QAMemberID
    WHERE QR.recordNumber = @recordumber
      and qr.firstname, qr.lastname = @employeeName
END

而且qr.firstnameqr.lastname = @employeeName我知道最后一段代码是错误的......我怎样才能以正确的方式做到这一点?谢谢...

4

3 回答 3

0

不要在代码中将值连接在一起,而是使用参数 forfirstName和参数 for lastName,如下所示:

CREATE PROCEDURE [dbo].[Reassign]
    @recordumber int,
    @firstName,
    @lastName
AS
BEGIN
    UPDATE QR
    SET QR.QAMemberID = @QAMemberID
    FROM Roster AS QR
    INNER JOIN TeamMaster S TM 
        ON QR.QAMemberID = TM.QAMemberID
    WHERE QR.recordNumber = @recordumber
        and qr.firstname = @firstName, qr.lastname = @lastName
END
于 2013-08-19T17:20:43.747 回答
0

要使用下拉列表中的值,您可以在后面的代码中使用它

 if (myDropDown.SelectedIndex != 0) 
 {
     var myData = myDropDown.SelectedValue;

     // access Sproc and you can then pass myData


 }
于 2013-08-19T17:27:44.003 回答
0

qr.firstname + ' ' + qr.lastname = @employeeName如果您将这些字段与空格连接起来,则可以使用。

...
  and qr.firstname + ' ' + qr.lastname = @employeeName
...

但最好将两个参数传递到过程中:

CREATE PROCEDURE [dbo].[Reassign]
   @recordumber int
   @firstname,
   @lastname
AS
...
  and qr.firstname = @firstname and qr.lastname = @lastname
...
于 2013-08-19T17:30:39.767 回答