Solved

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

Posted on 2012-12-31
6
650 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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