Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:58:12+00:00 2026-06-02T23:58:12+00:00

I have a function (on vb.net) to get a data from a XMLWebService: Private

  • 0

I have a function (on vb.net) to get a data from a XMLWebService:

Private Function GetDataSchedule() As DataTable
    Dim xTable As Data.DataTable
    xTable = xMaster.GetSchedule()

    'Bind to DataTable
    Dim DT As New System.Data.DataTable
    DT.Load(xTable.DefaultView) '--> When I set a breakpoint, the error start from here

    Return DT
End Function

And then the function to call the GetDataSchedule() Function:

Public Sub ShowDataSchedule()
    Dim DSSchedule As New System.Data.DataSet
    DSSchedule.Tables.Add(GetDataSchedule) 

End Sub

But then when I executed the code, it results on get the error message:
Unable to cast object of type 'System.Data.DataView' to type 'System.Data.IDataReader'.

When I just execute the GetDataSchedule() Function, it return value, but when I make it separately to call the function, then it got error. Am I missing something? Need your help. Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:58:13+00:00Added an answer on June 2, 2026 at 11:58 pm

    Try this

    DSSchedule.Tables.Add(GetDataSchedule().Copy())
    

    Although, since you might get back a null reference from GetDataSchedule(), it would be better to re factor your code a bit:

    Dim schedule as Data.DataTable = GetDataSechedule()
    If Not IsNothing(schedule) Then
        DSSchedule.Tables.Add(schedule.Copy())
    End If
    

    Otherwise, your code will go boom if you try to perform a .Copy() on a null reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(sorry for the english) I have a ASP .net webservice that get data from
I have used $.ajax function to fetch data from C# in asp.net MVC3.0, Now
I have a site that need to get some data from a different sit
I have a program that get sensors data from a Como database and put
I'm using the wcf webapi to get data from my asp.net application, and trying
I have a .NET 3.5 C# library that uses OleDb to pull data from
I have an ASP.NET MVC Form, but the data from it needs to be
I have a VB.Net function which executes a Oracle Stored Proc and returns a
I have a generic function in VB.Net. I also have two classes called A
using .NET 3.5. I have a function I want to make multithreaded calls to.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.