Solved

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

Posted on 2012-12-31
6
651 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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