ASP.NET (C#): How do I cast RRS feed

  • Question

  • I am new to ASP.NET and not strong in C# and I am having a problem I hope someone can help me with (odds are I am leaving out a major step or two).

    What I am trying to do is have an ASP.NET Web Application which reads an Access database file in the application and displays customer information.  I created a drop down for the customers to be selected and labels for the information about each customer to be displayed as a customer was selected from the drop down.

    I was able populate the drop down with the customer names and have it compile ok, but when I tried to pull the address etc from the database file, I received the following error: 

    Cannot implicitly convert type 'System.Collections.IEnumerable' to 'System.Data.Dataview'  An explicit conversion exists (are you missing a cast?) 

    The error was associated with the line: currentCustomer = AccessDataSource...

    protected void Page_Load(object sender, EventArgs e)

                DataView currentCustomer = new DataView();

                currentCustomer = AccessDataSource.Select(DataSourceSelectArguments.Empty);


    According to the error message, I am supposed to do a conversion, but I have no idea how to do that and I was unable to find anything during my search.

    Any suggestions?  Thank you!!

    • Moved by Fei Hu Monday, February 5, 2018 6:43 AM Asp.Net related
    Saturday, February 3, 2018 6:11 AM

All replies

  • You need something like this,

     AccessDataSource ds = new AccessDataSource();

     DataView currentCustomer = (DataView)ds.Select(DataSourceSelectArguments.Empty);

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (kokkisajee) or Facebook (sajeetharan) profile for Sajeetharan at Stack Overflow, Q&A for professional and enthusiast programmers

    Saturday, February 3, 2018 6:46 AM
  • I am new to ASP.NET

    Any suggestions?  Thank you!!


    Saturday, February 3, 2018 3:53 PM
  • I am still unable to get it to work.  It seemed like this got me closer, but I was still receiving an error.  Par of my confusion in this is, I am trying to display the data from an Access Database file that is stored in App_Data.  That means the data is in the program right?  I am not actually going out to a server to access the data to display it, I am only accessing data from a database file.  I say that because much of what I read tells me to establish a connection to the server etc.  In my mind, I don't need to access the server, because the data is right in the application, isn't it?

    Saturday, February 3, 2018 6:32 PM
  • I am still unable to get it to work.  It seemed like this got me closer, but I was still receiving an error.  Par of my confusion in this is, I am trying to display the data from an Access Database file that is stored in App_Data.

    The Access database is not a suitable database for Web based solutions, because it is not a multi user database solution. You should be using MS SQL Server Express.  You should be using  Visual Studio's Service Based Database that is a SQL Express MDF file type.


    I know you are using datasets and datatables, since you started out using Access.



    You say you are new to ASP.NET. You don't know what you are doing. You want to know how to do the right things concerning ASP.NET, then the below forum is where you need to post.


    Saturday, February 3, 2018 7:15 PM
  • The documentation is a good place to get help. Look in SqlDataSource.Select Method (DataSourceSelectArguments). You can get there by going to AccessDataSource Class and then going to the Select method from there. The C# sample near the bottom has:

    DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

    And that is essentially what Sajeetharan is saying, right?

    Sam Hobbs

    Sunday, February 4, 2018 3:57 AM
  • Hi tddyballgm,

    This forum is discussing and asking the C# programming language, IDE, libraries, samples and tools, it will be more appropriate to ask your question at ASP.NET Forum.

    Thank you for your understanding.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 5, 2018 6:42 AM