?
Solved

Conversion from string "Timeofday" to type 'Integer' is not valid.

Posted on 2012-12-31
6
Medium Priority
?
654 Views
Last Modified: 2013-01-18
Conversion from string "Timeofday" to type 'Integer' is not valid.

 dvholidays = New DataView(dtholidays, "Date = '" & CDate(e.Day.Date) & "' and Username = 'Perkinsj'", "", DataViewRowState.CurrentRows)

            If dvholidays.Item("Timeofday").ToString IsNot "" Then
                Dim iamoff As String = dvholidays.Item("Timeofday").ToString
                '  Dim iamoff As String = dateallreadybooked.havei(e.Day.Date, "Perkinsj")
                Select Case iamoff
                    Case "Am"
                        am.ImageUrl = "Images/Dark_Blue_Button.jpg"
                        am.Enabled = True ' enable the button so the user can change this if they no longer want the day booked
                    Case "Pm"
                        pm.ImageUrl = "Images/Dark_Blue_Button.jpg"
                        pm.Enabled = True ' enable the button so the user can change this if they no longer want the day booked
                    Case "full"
                        full.ImageUrl = "Images/Dark_Blue_Buttonlarge.jpg"
                        full.Enabled = True ' enable the button so the user can change this if they no longer want the day booked
                End Select
            End If

Open in new window

0
Comment
Question by:runnerjp2005
[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
6 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38732372
instade of this dvholidays.Item("Timeofday").
You need to specify the row for which you want to get the value.

like

For Each myDRV In myView
    For i = 0 To myView.Table.Columns.Count - 1
      Console.Write(myDRV(i) & vbTab)
    Next
    Console.WriteLine()
  Next

refer
http://msdn.microsoft.com/en-us/library/23a0aths(v=vs.71).aspx
0
 

Author Comment

by:runnerjp2005
ID: 38732375
dvholidays should reutn 1 row or null anyway
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38732387
then you can save reukt in string variable
Dim myDRV As DataRowView
Dim timeofday As String
timeofday = ""
For Each myDRV In dvholidays
    For i = 0 To myView.Table.Columns.Count - 1
      timeofday = myDRV(i)
    Next
   Next
then work on this variable

if you know exact column number , use that
For Each myDRV In dvholidays
          timeofday = myDRV(1)
     Next
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38732427
There is no overload of the Item property that takes a string (i.e. column name) as its parameter. You have to index by column position.

e.g.

If dvholidays.Item(0).ToString IsNot "" Then

Open in new window


Also, the IsNot should be a <> instead.

If dvholidays.Item(0).ToString <> "" Then

Open in new window

0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38733570
@kaufmed

>There is no overload of the Item property that takes a string (i.e. column name)

Sure?

http://msdn.microsoft.com/en-us/library/0k5w061k.aspx

>If dvholidays.Item(0).ToString IsNot "" Then
That would be

If dvholidays.Item(0).Item(0).ToString IsNot "" Then

right? (sorry could not resist)



@runnerjp2005

Change this

If dvholidays.Item("Timeofday").ToString IsNot "" Then

to

If dvholidays.Item(0).Item("Timeofday").ToString IsNot "" Then


The syntax is

DataView.Item(ROWINDEX).Item(COLUMNINDEX or COLUMNNAME)
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38733606
@CodeCruiser

Thanks, I thought there was, but I couldn't find it for some reason when I searched. I must have found dated documentation, or something.
0

Featured Post

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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