2010-03-29 4 views
0

원래 멀티 뷰에서 뷰를 전환하여 발생하는 프로세스를 만들었으므로 제대로 작동했습니다. 이제,이 동일한 코드를 ASP.NET 마법사로 옮겨서 두 번째 단계에서 오류가 계속 발생합니다. 오류 : 메서드 'System.Object AndObject (System.Object, System.Object)'에 SQL에 대한 지원되는 변환이 없습니다. 코드를 마법사로 옮길 때 이것이 일어나는 이유는 무엇입니까? 나는 그 무언가가 바보 같을 것이라고 확신하지만, 코드 3-4 번을 점검했고 작동 상 동일하게 보입니다. 다음은 코드입니다. '사용 가능한 .NET Framework의 LDAP 부분이 있는지 확인하십시오. Imports System.DirectoryServices 'LDAP와의 인터페이스를 허용합니다. Imports System.Data.Linq.SqlClient 'LINQ SQL 메서드를 사용할 수 있습니다.MultiView로 작업 한 코드가 Wizard ASP.NET에서 실패합니다.

부분 Public 클래스 buildit 상속 System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
    ' ******* Grab the LDAP info. for current user. 
    Dim ID As FormsIdentity = DirectCast(User.Identity, FormsIdentity) 
    Dim ticket As FormsAuthenticationTicket = ID.Ticket 
    Dim adDirectory As New DirectoryEntry("LDAP://OU=[info],DC=[info],DC=[info],DC=[info]") 
    ' We need to strip off @email.address from the ticket name, so we'll use substring to grab the first 
    ' five characters. 
    Dim adTicketID As String = ticket.Name.Substring(0, 5) 
    Dim adEmployeeID As String 
    adEmployeeID = adDirectory.Children.Find("CN=" & adTicketID).Properties("employeeID").Value 

    ' ******* Lets make sure they have signed the housing contract and the community covenant. 
    Dim dbContractSigs As New pcRoomOccupantsDataContext 
    Dim pcContractSigs = From p In dbContractSigs.webContractSigs _ 
         Where p.people_id = adEmployeeID _ 
         Select p.res_contract, p.comm_life 
    If pcContractSigs.Count.Equals(0) Then 
     Response.Redirect("signcontract.aspx") 
    Else 
     Dim cs As String = pcContractSigs.First.res_contract.ToString 
     Dim cos As String = pcContractSigs.First.comm_life.ToString 
     If cs = "Y" And cos = "Y" Then 
      ' We don't need to do anything. 
      ' We use the else statement b/c there are multiple conditions that could occur besides "N" 
      ' that would cause us to redirect to the signature page, whereas there is only one valid response - "Y". 
     Else 
      ' Redirect the individual to our contracts page. 
      Response.Redirect("signcontract.aspx") 
     End If 
    End If 

    ' ******* Now lets find out what gender that individual is. 
    Dim dbIndividual As New pcPeopleDataContext 
    Dim pcIndividual = From p In dbIndividual.PEOPLEs _ 
         Join d In dbIndividual.DEMOGRAPHICs On p.PEOPLE_CODE_ID Equals d.PEOPLE_CODE_ID _ 
         Where p.PEOPLE_ID = adEmployeeID _ 
         Select p, d 
    ' Make a session variable that will carry with the user throughout the session delineating gender. 
    Session("sgender") = pcIndividual.First.d.GENDER.ToString 
    ' Debug Code. 
    ' Put a stop at end sub to get these values. 
    ' Response.Write(adEmployeeID) 

End Sub 
Sub LinqDataSource1_Selecting(ByVal sender As Object, ByVal e As LinqDataSourceSelectEventArgs) 
    ' Lets get a list of the dorms that are available for user's gender. 
    Dim pcDorms As New pcDormsDataContext 
    Dim selectedDorms = (From sd In pcDorms.PBU_WEB_DORMs _ 
        Where IIf(Session("sgender").ToString = "M", sd.description = "Male", sd.description = "Female") _ 
        Select sd.dorm_building).Distinct() 
    e.Result = selectedDorms 
End Sub 
Public Sub Button_ItemCommand(ByVal Sender As Object, ByVal e As RepeaterCommandEventArgs) 
    ' ******** Lets pass on the results of our query in LinqDataSource1_Selecting. 
    Session("sdorm") = RTrim(e.CommandName) 

    ' ******** Debug code. 
    ' Response.Write(sDorm) 
End Sub 
Sub LinqDataSource2_Selecting(ByVal sender As Object, ByVal e As LinqDataSourceSelectEventArgs) 
    ' ******** Get a list of rooms available in the dorm for user's gender. 
    Dim pcDorms As New pcDormsDataContext 
    Dim selectedDorm = (From sd In pcDorms.PBU_WEB_DORMs _ 
         Where IIf(Session("sgender").ToString = "M", sd.description = "Male", sd.description = "Female") _ 
         And sd.dorm_building = CStr(Session("sdorm")) _ 
         Select sd.dorm_room) 
    e.Result = selectedDorm 
End Sub 
Public Sub Button2_ItemCommand(ByVal Sender As Object, ByVal e As RepeaterCommandEventArgs) 
    ' ******** Lets pass on the results of our query in LinqDataSource2_Selecting. 
    Session("sroom") = RTrim(e.CommandName) 
End Sub 
Sub LinqDataSource3_Selecting(ByVal sender As Object, ByVal e As LinqDataSourceSelectEventArgs) 
    ' ******** Grabs the individuals currently listed as residing in this room and displays them. Note the use of SqlMethods.Like 
    ' for dorm_building, this is due to legacy issues where dorms sometimes have leading or trailing blank spaces. We could have 
    ' also used Trim. 
    Dim pcOccupants As New pcRoomOccupantsDataContext 
    Dim roomOccupants = (From ro In pcOccupants.webResidents _ 
         Where SqlMethods.Like(ro.dorm_building, "%" & CStr(Session("sdorm")) & "%") _ 
         And ro.dorm_room = CStr(Session("sroom")) _ 
         Select ro.person_name) 
    e.Result = roomOccupants 

    ' ******** Debug code. 
    'Response.Write(CStr(Session("sdorm"))) 
    'Response.Write(CStr(Session("sroom"))) 
End Sub 
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button4.Click 
    ' ******** Reserve the room for a student. 
End Sub 

최종 클래스

답변

1

내 예전의 코드는 다음과 같이 보았다 :

Dim selectedDorm = (From sd In pcDorms.PBU_WEB_DORMs _ 
          Where IIf(Session("sgender").ToString = "M", sd.description = "Male", sd.description = "Female") _ 
          And sd.dorm_building = Session("sdorm").ToString _ 
          Select sd.dorm_room) 

그리고 작동하지 않는 (그러나 MultiViews를를 사용하는 경우 작업을했다). 이것을 다음과 같이 변경했습니다.

Dim selectedDorm = (From sd In pcDorms.PBU_WEB_DORMs _ 
          Where IIf(Session("sgender").ToString = "M", sd.description = "Male", sd.description = "Female") _ 
          Where sd.dorm_building = Session("sdorm").ToString _ 
          Select sd.dorm_room) 

이제는 작동합니다.

0

코드를 보지 않고 말할 수 없다; DB에서 일부 정보를 가져 오는 LINQ 쿼리가 있는데, 이제는 오류가 발생합니다. 그러나 코드를 보지 않고는 아무 것도 말할 수 없습니다.

+0

방금 ​​코드를 추가했습니다. 희망이 도움이됩니다. :) – davemackey

관련 문제