none
How to employ the dataset I have created RRS feed

  • Question

  • I have created this solution in Visual Studio 2010 previously. What I need now is a reference to documentation, or a sample of code that might provide what I need. I have a form that has textboxes for email and password. I have a table that contains these items. I have defined a dataset and an adapter for use in my code-behind logic.  Basically the statement  that I have a problem with is:  dim dvsql as        dataview=DirectCast(sqldatasource1.select(datasourceSelectArguments.Empty),dataview) .  I came by this from my vs2010 application and I do not know how to correct the problems or where to read up on what I need to do.  I will appreciate any kind of help that will resolve my difficulty.


    eps123


    
    
    
    • Edited by eps123 Tuesday, August 4, 2015 7:42 PM
    Tuesday, August 4, 2015 6:59 PM

Answers

  • I'm assuming that sqldatasource1 is what was generated by MSDataSetGenerator in your VS2010 code. I don't know why you didn't just copy all of that over to your VS2013 code, but I guess you didn't.

    Anyway, when you recreated your DataSet (looks like it's DataSet1.xsd), VS2013 should also generate the DataSet and TableAdapter code. In your Solution Explorer, take a look under the DataSet1.xsd, and you should see a DataSet1.Designer.cs file. All your generated code is there.

    Now, here's where I'm not going to be much too help to you. I had never seen anything like "datasourceSelectArguments" before (and I use Typed DataSets a lot) so I Googled ... the reason I hadn't encountered this is because I'm not a web developer and this appears to be a web thing. So, am I correct to assume that your project is an ASP.NET application? Go ahead and Google that ("datasourceselectarguments") and you'll find lots of stuff about it.

    I'm thinking that you will probably find something containing the "SelectArguments" in your generated code somewhere. Just do a "Find" in VS for "SelectArguments" for the whole solution and I'll bet you find what it's actually called in your newly generated code.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by eps123 Wednesday, August 5, 2015 5:17 PM
    Wednesday, August 5, 2015 4:49 PM
  • Well, that's just it ... I'm not sure what that code does, because I'm not familiar with DataSourceSelectArguments in ASP.NET.  However, it looks like you want to get a DataView, which you get from a DataTable in your DataSet. I don't know what your DataTables are called in your DataSet, but I'll give you an example of getting a DataView (excuse me if my VB syntax is not quite right, I use C#).

    Dim filter As String = "TheColumn = " + "WhateverTheValueIs"
    Dim dvSql as DataView = new DataView(theDataSet.TheDataTable)
    dvSql.RowFilter = filter
    
    For Each row As DataRowView In dvSql
        ' do stuff with each row in this loop
    Next
    
    If I have some time, I'll look through the posts on my blog for something else that might be useful for you. Lacking that, again if I have some time, I can see if I can dig up any other good links for you. What's difficult in doing that is that I'm not sure you need to know or want to know. Let me know if that above DataView stuff helps you or not. And let me know if you find anything useful on my blog (if you wanted to bother looking there).


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by eps123 Thursday, August 6, 2015 3:11 PM
    Thursday, August 6, 2015 12:46 AM
  • The only reason I used DataSet1 in my example, is because that appeared to be the name of the Typed DataSet class (from your previous postings). Looking at the image you posted, the DataSet class you've currently got is called MYDBCONNECTIONDataSet. So all you have to do is change this:

    Dim theDataSet As DataSet = New MYDBCONNECTIONDataSet()

    ... to this:

    Dim theDataSet As MYDBCONNECTIONDataSet = New MYDBCONNECTIONDataSet()

    That should solve all of these problems.

    However, you still probably should follow some of the advice in that link I provided you with, since this solution that we're currently "playing with" is probably not optimal for a Web application (as yours appears to be).


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com


    • Edited by BonnieBMVP Friday, August 14, 2015 8:04 PM bold for emphasis
    • Marked as answer by eps123 Monday, August 17, 2015 5:36 PM
    Friday, August 14, 2015 8:03 PM
  • Bonnie thanx again.  We're almost there.  Latest result Which I thought I posted Friday, is shown below.  Any idea what to do about it and why it is an unknown reference?  I've tried to clean up the solution since I have repeated the dataset and adapter definitions acouple of times only thing I can think of is to repeat from scratch retaining only the two table definitions that I have.  That seems stupid without knowing what pain it now.


    eps123

    • Marked as answer by eps123 Wednesday, August 19, 2015 2:04 PM
    Monday, August 17, 2015 5:49 PM
  • Sorry for not getting back to you sooner. I've been on vacation without internet access.

    I see that you marked your last reply as an answer, but I don't understand why because you were still asking questions in that last reply.

    To me, it looks like the problem is that you didn't create an instance of LOGINTableAdapter, which is what you need to do before you can call its Fill() method.

    Dim theTableAdapter As LOGINTableAdapter = New LOGINTableAdapter()
    theTableAdapter.Fill(theDataSet.LOGIN)
    

    Is that what you ended up doing a week ago?


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by eps123 Wednesday, August 26, 2015 8:21 PM
    Tuesday, August 25, 2015 4:28 PM

All replies

  • Could you tell us what the problems are?

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Tuesday, August 4, 2015 7:55 PM
  • hopefully my response and the two images I have pasted in below will provide the the answer to my problems.  The solutions that are proposed by vs2013 are somewhat bewildering to me because I am obviously behind in having a full understanding.  Both problems on that same line occur because the line itself is derived from my VS2010 environment which has ceased to exist.  I have built the dataset in VS2013.  I need to know how to investigate what datasource is resulting from the definition.  I would also need to have some documentation on the use of the "directcast routine that is using the two arguments that are flagged.  If the above requests are too difficult to get answers, I would like some small tips on how to cycle thru the contents of a dataset that is provided.  Where do I find that in an example or documentation?  Thank you in advance and please don't hesitate to ak for more definition if I still have not clarified.


    eps123

    Wednesday, August 5, 2015 2:30 PM
  • I'm assuming that sqldatasource1 is what was generated by MSDataSetGenerator in your VS2010 code. I don't know why you didn't just copy all of that over to your VS2013 code, but I guess you didn't.

    Anyway, when you recreated your DataSet (looks like it's DataSet1.xsd), VS2013 should also generate the DataSet and TableAdapter code. In your Solution Explorer, take a look under the DataSet1.xsd, and you should see a DataSet1.Designer.cs file. All your generated code is there.

    Now, here's where I'm not going to be much too help to you. I had never seen anything like "datasourceSelectArguments" before (and I use Typed DataSets a lot) so I Googled ... the reason I hadn't encountered this is because I'm not a web developer and this appears to be a web thing. So, am I correct to assume that your project is an ASP.NET application? Go ahead and Google that ("datasourceselectarguments") and you'll find lots of stuff about it.

    I'm thinking that you will probably find something containing the "SelectArguments" in your generated code somewhere. Just do a "Find" in VS for "SelectArguments" for the whole solution and I'll bet you find what it's actually called in your newly generated code.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by eps123 Wednesday, August 5, 2015 5:17 PM
    Wednesday, August 5, 2015 4:49 PM
  • Thanks bonnie, I've marked it as an answer for which I am grateful.  I am prepared to do as directed, but I would still be more comfortable with a replacement for the 2010 call I have introduced.  I come from a different century and the fewer disciplines that I need to master or confront, the better off I am.  I am only trying to loop thru the rows of a dataset to obtain my values and I lack the code or the document where I can learn how to do this. 

    Thanx again


    eps123

    Wednesday, August 5, 2015 5:28 PM
  • Well, that's just it ... I'm not sure what that code does, because I'm not familiar with DataSourceSelectArguments in ASP.NET.  However, it looks like you want to get a DataView, which you get from a DataTable in your DataSet. I don't know what your DataTables are called in your DataSet, but I'll give you an example of getting a DataView (excuse me if my VB syntax is not quite right, I use C#).

    Dim filter As String = "TheColumn = " + "WhateverTheValueIs"
    Dim dvSql as DataView = new DataView(theDataSet.TheDataTable)
    dvSql.RowFilter = filter
    
    For Each row As DataRowView In dvSql
        ' do stuff with each row in this loop
    Next
    
    If I have some time, I'll look through the posts on my blog for something else that might be useful for you. Lacking that, again if I have some time, I can see if I can dig up any other good links for you. What's difficult in doing that is that I'm not sure you need to know or want to know. Let me know if that above DataView stuff helps you or not. And let me know if you find anything useful on my blog (if you wanted to bother looking there).


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by eps123 Thursday, August 6, 2015 3:11 PM
    Thursday, August 6, 2015 12:46 AM
  • Thank you so much for the answer that I have marked accordingly. I must confess that I have been consorting with another Geekgodess and she has provided me with a similar chunk of code. In trying to use it I met with moderate success but still ran into responses that were bewildering. What I have gleaned thus far is that I need to be more careful in selecting tools (such as a dataset) because in the long run you need to understand them much more than byname and icon. Thus I am starting over in creating the dataset and playdata for testing. My guess as to what was wrong in my previous dilemma, is that my dataset (which wasn;t even referenced correctly), was untyped leading me to the problems.

    I will let you know of my progress because the flavor of your response indicates where I would like to be.


    eps123

    Thursday, August 6, 2015 3:27 PM
  • You *are* writing a web application, right? I have some posts on my blog about DataSets and DataAccess, but they're geared more towards Windows applications, rather than web. I have a feeling that they wouldn't be appropriate for web ("appropriate" isn't the right word, I probably should say "efficient" instead).

    But, I found this PDF that I think might be more helpful to you than I can be. Take a look at it:

    http://ir.nmu.org.ua/bitstream/handle/123456789/141087/54ce66c1c0227f2f42dc499b18c31511.pdf?sequence=1


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Thursday, August 6, 2015 4:28 PM
  • Thank you much for the link you sent me. I have downloaded the pdf and it looks promising after a cursory look. I am still intrigued or obsessed with making the snippet you sent me work. I've got a table on my design surface which now is the correct dataset. It also reflects a tableadaptor link on it. I freely admit my ignorance as to how and where to apply the code you gave me. Ive tried to insert it within my button code after making the right substitutions. I'll include what the modified routine looks like and will appreciate your telling me I'm close (or if I need to read a lot more tell me that) and I'll understand.

    What is the "fill routine" that is provided in the adapters?  Is that something that I can call to give me the equivalent of dvsql in your code?


    eps123


    Partial Class DataSet1
        Partial Class LOGINDataTable
           
        
    End Class
    
        'Namespace DataSet1TableAdapters
    
        Partial Class LOGINTableAdapter
            Dim filter As String = "Password = " + "P(u1)"
            Dim dvSql As DataView = New DataView(DataSet1.LOGINRow)
    
    dvSql.RowFilter = filter
    
    For Each row As DataRowView In dvSql
            ' do stuff with each row in this loop
    Next
        End Class
    
    End Class
    
        Partial Public Class loginTableAdapter1
        End Class
    'End Namespace
    

    • Edited by eps123 Monday, August 10, 2015 2:48 PM
    Monday, August 10, 2015 2:43 PM
  • So sorry for the slow reply!

    I freely admit my ignorance as to how and where to apply the code you gave me. Ive tried to insert it within my button code after making the right substitutions.

    I assume you mean the code for getting the DataView? That code goes where you were getting the error trying to get a DataView from the code "sqldatasource1.select(datasourceSelectArguments)", which was in your Button1_Click handler, so yes, you've done that part right. Does it not work? Does it look like the code you've posted?

    But, here's the thing ... it looks like the code you just posted is in a partial class of the TableAdapter (not your button click), so I'm not sure what you're doing now. Sorry.

    And anyway, it doesn't look right ... the creation of a DataView takes an instance of a DataTable, it doesn't look like that's what you've got there. It looks like you've got a DataSet class, called DataSet1. And in that DataSet, you've got a DataTable called LOGIN. Now, you've got to pass an instance of your DataTable to the "New DataView" to get a DataView returned. Like this (this would be in your button click):

    Dim theDataSet As DataSet1 = New DataSet1()
    LOGINTableAdapter.Fill(theDataSet.LOGIN) ' Fills the LOGIN DataTable from the database
    
    ' now get the DataView
    Dim filter As String = "Password = " + "P(u1)"
    Dim dvSql as DataView = new DataView(theDataSet.LOGIN)
    dvSql.RowFilter = filter
    
    For Each row As DataRowView In dvSql
        ' do stuff with each row in this loop
    Next
    

    What is the "fill routine" that is provided in the adapters?  Is that something that I can call to give me the equivalent of dvsql in your code?

    No, the Fill is what puts the data from your database into your DataSet/DataTable ... I assume you're already doing that somewhere, you can see I used that in the example above.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Thursday, August 13, 2015 4:17 PM
  • Thank you Bonnie.  While I've been trying to do more reading and investigating, I still welcome your attempts to give me an answer.  I tried to incorporate your idea and got stopped on two issues both involving "thedataset".  I attempted adjustments by accepting some proposed suggestions.  The first was to change the reference to "dataset1" to "dataset".  It seemed reasonable to me because I saw no reference in my solution explorer view to indicate dataset1.  I tried to streamline my solution by eliminating some references that were coming up which I believed were probable caused by my repeated  attempts.  I retested after this and everything tests well as before.  The only problem that persists is the definition of "thedataset"  Ive tried some variations on this depending on what I see in SOLOUTION EXPLORER.  I am pasting in my image in the hope that you care to dig in a little more and cab suggest something that I am doing wrong.

    eps123

    Friday, August 14, 2015 6:06 PM
  • The only reason I used DataSet1 in my example, is because that appeared to be the name of the Typed DataSet class (from your previous postings). Looking at the image you posted, the DataSet class you've currently got is called MYDBCONNECTIONDataSet. So all you have to do is change this:

    Dim theDataSet As DataSet = New MYDBCONNECTIONDataSet()

    ... to this:

    Dim theDataSet As MYDBCONNECTIONDataSet = New MYDBCONNECTIONDataSet()

    That should solve all of these problems.

    However, you still probably should follow some of the advice in that link I provided you with, since this solution that we're currently "playing with" is probably not optimal for a Web application (as yours appears to be).


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com


    • Edited by BonnieBMVP Friday, August 14, 2015 8:04 PM bold for emphasis
    • Marked as answer by eps123 Monday, August 17, 2015 5:36 PM
    Friday, August 14, 2015 8:03 PM
  • Bonnie thanx again.  We're almost there.  Latest result Which I thought I posted Friday, is shown below.  Any idea what to do about it and why it is an unknown reference?  I've tried to clean up the solution since I have repeated the dataset and adapter definitions acouple of times only thing I can think of is to repeat from scratch retaining only the two table definitions that I have.  That seems stupid without knowing what pain it now.


    eps123

    • Marked as answer by eps123 Wednesday, August 19, 2015 2:04 PM
    Monday, August 17, 2015 5:49 PM
  • Sorry for not getting back to you sooner. I've been on vacation without internet access.

    I see that you marked your last reply as an answer, but I don't understand why because you were still asking questions in that last reply.

    To me, it looks like the problem is that you didn't create an instance of LOGINTableAdapter, which is what you need to do before you can call its Fill() method.

    Dim theTableAdapter As LOGINTableAdapter = New LOGINTableAdapter()
    theTableAdapter.Fill(theDataSet.LOGIN)
    

    Is that what you ended up doing a week ago?


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by eps123 Wednesday, August 26, 2015 8:21 PM
    Tuesday, August 25, 2015 4:28 PM
  • Thanks for the response Bonnie.  I had too many datasets and filters and when I cleaned things up it finally behaved.  I think I even learned a bit in the exercise. 


    eps123

    Wednesday, August 26, 2015 8:24 PM
  • That's great that you got it working!! And learned a bit in the process, too ... even better!!

    Good luck with your project!  =0)


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, August 29, 2015 4:37 PM