Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mobile ObjectList problem loadind array The DataField 'TheTime' does not exist in the source data?

Posted on 2007-11-25
3
Medium Priority
?
530 Views
Last Modified: 2010-04-21
Hi,

This is perplaxing.  I am new to development for mobile application so maybe I am missing something.
I want the players in my hockey league to have mobile cell phone access to the league schedule.  I can do this but when I add an extra field "TheTime", I get the following error:

The DataField 'TheTime' does not exist in the source data.  Specify a different DataField property, or remove the field.

I KNOW this field exists and when I write the code for a regular data reader, no problem.  I am using the same sql stored procedure for both.

Here's my sub.  I've created a class to hold the gameschedule so I can have more than one field in the objectlist.  This works on the web now at www.qiihl.com/mobile/default.aspx but as soon as I try to add TheTime field everything crashes:

Code attached



<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
 
<script runat="server">
    Private Class GameSchedule
 
        Dim _thedate, _time, _hometeam, _awayteam, _venue As String
 
        Public Sub New(ByVal thedate As String, ByVal thetime As String, ByVal hometeam As String, ByVal awayteam As String, ByVal venue As String)
                      
            _thedate = thedate
            _time = time
            _hometeam = hometeam
            _awayteam = awayteam
            _venue = venue
            
 
        End Sub
 
        Public ReadOnly Property hometeam() As String
            Get
                Return _hometeam
            End Get
        End Property
 
        Public ReadOnly Property awayteam() As String
            Get
                Return _awayteam
            End Get
        End Property
        
        Public ReadOnly Property thedate() As String
            Get
                Return _thedate
            End Get
        End Property
        
        Public ReadOnly Property venue() As String
            Get
                Return _venue
            End Get
        End Property
        
        Public ReadOnly Property time() As String
            Get
                Return _time
            End Get
        End Property
 
   
    End Class
 
 
    Sub Page_Load()
 
        If Not Page.IsPostBack Then
 
            Dim myConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
            myConnection.Open()
            Dim myCommand = New SqlCommand("qGetTeamsInfoForGridView", myConnection)
            myCommand.CommandType = Data.CommandType.StoredProcedure
            Dim reader As SqlDataReader = myCommand.ExecuteReader()
            List1.DataSource = reader
            ' Dim teamid As Integer
            ' Dim shortname As String
                 
            If reader.HasRows Then
             
                List1.DataTextField = "ShortName"
                List1.DataValueField = "TeamID"
                List1.DataBind()
       
            
            End If
            
            reader.Close()
            myConnection.Close()
	
        End If
 
    End Sub
    
    Sub GetTeamSchedule(ByVal Src As Object, ByVal Args As ListCommandEventArgs)
        
             
        Dim teamname As String
        Dim teamid As Integer
        teamid = Args.ListItem.Value
        teamname = Args.ListItem.Text
        Dim myConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
        myConnection.Open()
        Dim myCommand = New SqlCommand("qGetScheduleWithTeamID", myConnection)
        myCommand.CommandType = Data.CommandType.StoredProcedure
        myCommand.Parameters.Add(New SqlParameter("@teamid", Data.SqlDbType.Int))
        myCommand.Parameters("@teamid").Value = teamid
        Dim reader As SqlDataReader = myCommand.ExecuteReader()
        Dim schedulearray As New ArrayList()
      
        If reader.HasRows Then
            While reader.Read() = True
                schedulearray.Add(New GameSchedule(reader("TheDate"), reader("TheTime"), reader("hometeam"), reader("awayteam"), "C_Center"))
            End While
            Title.Text = "Two Weeks - Schedule: " & teamname
            
            ObjectListSchedule.DataSource = schedulearray
            ObjectListSchedule.DataBind()
        End If
        
        reader.Close()
        myConnection.Close()
        ActiveForm = Form2
    End Sub
 
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server">
        <mobile:Label ID="Label1" Runat="server">QIIHL Teams: Schedule</mobile:Label>
        <mobile:Label ID="Label2" Runat="server">Choose Team</mobile:Label>
        <br />
        <mobile:List ID="List1" Runat="server"  OnItemCommand="GetTeamSchedule" >
     
     
        </mobile:List>
 
    </mobile:form>
    <mobile:Form ID="Form2" Runat="server">
    <mobile:Label ID="Title" runat="server" StyleReference="title" Font-Size="Small">Schedule</mobile:Label>
       <mobile:ObjectList
        ID="ObjectListSchedule" 
        Runat="server" 
        AutoGenerateFields="False" 
        TableFields="TheDate;TheTime;HomeTeam;AwayTeam" CommandStyle-StyleReference="subcommand" Font-Size="Small" LabelStyle-StyleReference="title">
           <Field DataField="TheDate" Name="TheDate" Title="Date" />
           <Field DataField="TheTime" Name="TheTime" Title="Time" />
           <Field DataField="HomeTeam" Name="HomeTeam" Title="Home" />
           <Field DataField="AwayTeam" Name="AwayTeam" Title="Away" />
        
        
</mobile:ObjectList> 
        <mobile:Link ID="Link1" Runat="server" NavigateUrl="#form1">Team List</mobile:Link>
</mobile:Form>
 
</body>
</html>

Open in new window

0
Comment
Question by:vstack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
gocemi earned 1500 total points
ID: 20348709
Hi,

Do you fetch "TheTime" - field from the DB?
Do you convert data in String?
start the debug, add breakpoint on line  102 and view "reader" properties in the QuickWatch window

Regards
0
 

Author Comment

by:vstack
ID: 20349198
I fetch it from the DB.  I will try .ToString.  Thanks
0
 

Author Closing Comment

by:vstack
ID: 31410862
Thanks, I've finally worked this out.  Part of the solution was the .ToString on the date
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question