Solved

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

Posted on 2012-12-31
6
637 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
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 74

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 74

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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 …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now