0

此网络方法从数据库中检索 plist、firstaname、lastname、orgid,然后在 2 个不同的表中插入 2 行。第一个 sql 很好 - 第二个不运行

<WebMethod()> _
Public Function Register(ByVal meetingid As String, ByVal myid As String, ByVal PartType As Integer, ByVal startDate As String) As String
    Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("EPBconnection").ConnectionString)
    Dim sSQL As String
    Dim plistid As String = ""
    Dim LastName As String = ""
    Dim FirstName As String = ""
    Dim orgID As String = ""

    'get plistID
    sSQL = "select pl.PLIST_ID"
    sSQL = sSQL + " From PERSON_LIST pl"
    sSQL = sSQL + " Where MTG_ID = '" + meetingid + "'"
    Dim myCommand As New SqlCommand(sSQL, connection)
    connection.Open()
    Dim myReader As SqlDataReader = myCommand.ExecuteReader
    While myReader.Read()
        plistid = myReader("PLIST_ID").ToString()
    End While
    connection.Close()

    'get firstname, lastname, orgid
    sSQL = "SELECT p.LASTNAME, p.FIRSTNAME, p.ORGA_ID FROM PERSON p WHERE PERSON_ID = '" + myid + "'"
    myCommand = New SqlCommand(sSQL, connection)
    connection.Open()
    myReader = myCommand.ExecuteReader
    While myReader.Read()
        LastName = myReader("LASTNAME").ToString()
        FirstName = myReader("FIRSTNAME").ToString()
        orgID = myReader("ORGA_ID").ToString()
    End While
    connection.Close()

    Return "You are registered for this meeting"

End Function

当我删除以下内容时,它会返回字符串,但否则不会(无论哪种方式编译都没有错误):

While myReader.Read()
    LastName = myReader("LASTNAME").ToString()
    FirstName = myReader("FIRSTNAME").ToString()
    orgID = myReader("ORGA_ID").ToString()
End While

问题似乎来自 myReader.Read()??? 我不明白为什么

4

2 回答 2

3
 orgID = myReader("ORGA_ID").ToString() 

您已将 orgId 定义为 Integer;

  Dim orgID As Integer
于 2013-03-04T17:23:43.620 回答
0

抱歉,问题在一夜之间自行解决了。还是不知道是什么问题。哈哈

于 2013-03-06T15:27:53.973 回答