此webmethod从数据库中检索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()???我不明白为什么
答案 0 :(得分:3)
orgID = myReader("ORGA_ID").ToString()
您已将orgId定义为整数;
Dim orgID As Integer
答案 1 :(得分:0)
对不起每一个问题都是自己解决了一夜。仍然不知道问题是什么。 LOL