Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. dataRows, dataCols, etc...?

dataRows, dataCols, etc...?

Scheduled Pinned Locked Moved Visual Basic
databasequestionlearning
13 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kowplunk
    wrote on last edited by
    #1

    I am a little confused with all of these. Right now to pull data from the db ans display it I use a dataAdaptor, dataSet, dataGris, and a dataView. Now this all works for me, but I am sure that I am only skimmig the surface. Seeing as everything works with what I use, what are dataRows, and DataCols for? Are they for creating your own columns within a pre-defined or manually created dataSet. I am presently trying to replace a class structure simular to a Book->page->word like structue with a dataset, and use dataviews to view all the data the corresponds to the page being viewed, and I think that this might be a much better way than what I have now. Thanks for any input.

    M 1 Reply Last reply
    0
    • K kowplunk

      I am a little confused with all of these. Right now to pull data from the db ans display it I use a dataAdaptor, dataSet, dataGris, and a dataView. Now this all works for me, but I am sure that I am only skimmig the surface. Seeing as everything works with what I use, what are dataRows, and DataCols for? Are they for creating your own columns within a pre-defined or manually created dataSet. I am presently trying to replace a class structure simular to a Book->page->word like structue with a dataset, and use dataviews to view all the data the corresponds to the page being viewed, and I think that this might be a much better way than what I have now. Thanks for any input.

      M Offline
      M Offline
      Murugavel S
      wrote on last edited by
      #2

      DataRow represents a single row of a datatable. i.e to display / insert a single row of a datatable. DataColumn represents a single column of a datatable. A new column can be created in the datatable in otherwords to create the schema of Datatable. You can set Constraints, Identity, Null/Not Null. Now, datarow can be used to create a new row in a datacolumn. Basically, think the above two as equivalent to the action that you carry out in your database server. Cheers ;)

      K 1 Reply Last reply
      0
      • M Murugavel S

        DataRow represents a single row of a datatable. i.e to display / insert a single row of a datatable. DataColumn represents a single column of a datatable. A new column can be created in the datatable in otherwords to create the schema of Datatable. You can set Constraints, Identity, Null/Not Null. Now, datarow can be used to create a new row in a datacolumn. Basically, think the above two as equivalent to the action that you carry out in your database server. Cheers ;)

        K Offline
        K Offline
        kowplunk
        wrote on last edited by
        #3

        I am not sure if this way of thinking is right, but... Are creating data columns and dataRows, used more for allowing for control of what is going into the dataTable? I was thinking that maybe when using the dataAdaptor that the dataCols, etc is all down behind the scene. Another question though. I can't seem to figure out how to set up a data view to only show certain columns. There is a rowFilter, which is obviously like the where clause in an sql string, but right now I need to be able to only show the cols that I want. Does anyone know how to do this. The book that I found only has a half a page on the dataView so there is not much detail on this subject. Thanks for the help

        J 1 Reply Last reply
        0
        • K kowplunk

          I am not sure if this way of thinking is right, but... Are creating data columns and dataRows, used more for allowing for control of what is going into the dataTable? I was thinking that maybe when using the dataAdaptor that the dataCols, etc is all down behind the scene. Another question though. I can't seem to figure out how to set up a data view to only show certain columns. There is a rowFilter, which is obviously like the where clause in an sql string, but right now I need to be able to only show the cols that I want. Does anyone know how to do this. The book that I found only has a half a page on the dataView so there is not much detail on this subject. Thanks for the help

          J Offline
          J Offline
          Jim Matthews
          wrote on last edited by
          #4

          datacolumns are used for defining the structure or schema of the data table. so, in a sense, yes your thinking is correct. when using dataadapter.fill, the datatable you point to assumes the structure of the resulting data. for data views, i don't believe you can filter columns out of a view. to do this, you would use whatever tool you're using to display the data table to the user. i.e. a datagrid or combobox etc. if using a datagrid, define a tablestyle for your datagrid and then define a gridcolumnstyle for each column you wish to actually display. don't define one for the columns you wish to hide, or you could define the grid columnstyle for the ones you wish to hide and just set their width property to 0. hope this helps.


          - jim

          K 1 Reply Last reply
          0
          • J Jim Matthews

            datacolumns are used for defining the structure or schema of the data table. so, in a sense, yes your thinking is correct. when using dataadapter.fill, the datatable you point to assumes the structure of the resulting data. for data views, i don't believe you can filter columns out of a view. to do this, you would use whatever tool you're using to display the data table to the user. i.e. a datagrid or combobox etc. if using a datagrid, define a tablestyle for your datagrid and then define a gridcolumnstyle for each column you wish to actually display. don't define one for the columns you wish to hide, or you could define the grid columnstyle for the ones you wish to hide and just set their width property to 0. hope this helps.


            - jim

            K Offline
            K Offline
            kowplunk
            wrote on last edited by
            #5

            that makes sense. I made things work by creating a custom table inserting only the cols that I want then the corresponding data for those columns, BUT if I make changes to that data, is it going to affect the data in the dataSet and therefore be able to be submitted, since the custom dataTable that is created is not part of the dataSet? Thanks again

            J 1 Reply Last reply
            0
            • K kowplunk

              that makes sense. I made things work by creating a custom table inserting only the cols that I want then the corresponding data for those columns, BUT if I make changes to that data, is it going to affect the data in the dataSet and therefore be able to be submitted, since the custom dataTable that is created is not part of the dataSet? Thanks again

              J Offline
              J Offline
              Jim Matthews
              wrote on last edited by
              #6

              no problem. i would advise against doing it the way you said you were able to get around your problem for two main reasons. 1. you are going to have problems updating back to the datasource. this is because you've changed the structure of the table. when you use fill from the dataadapter to populate a table the dataadapter itself holds information regarding the information that was pulled and automatically creates insert, update and delete statements based on the structure of what was initially pulled. you could certainly call myAdapter.Update(myNewTable) but it will no doubt cause problems because the structure has changed. This is of course unless you manually update the commandtext property of the corresponding commands to reflect the structure of the new table. 2. you are incurring an unnecessary performance hit by copying the data from the table that is returned by the adapter into a new table. this will be more of an issue as the amount of data returned increases. so basically, you can do it this way, but i don't really think it's necessary in your situation. my recommendation would be to just pull the data out using the dataadapter, let the user update the data, and use the same dataadapter to update, if possible. If using the same dataadapter isn't possible, then you have to look into how to set the properties of the dataadatper and it's underlying Insert, Update, and Delete Commands and their corresponding CommandText properties to get the data back into the database correctly.


              - jim

              K 1 Reply Last reply
              0
              • J Jim Matthews

                no problem. i would advise against doing it the way you said you were able to get around your problem for two main reasons. 1. you are going to have problems updating back to the datasource. this is because you've changed the structure of the table. when you use fill from the dataadapter to populate a table the dataadapter itself holds information regarding the information that was pulled and automatically creates insert, update and delete statements based on the structure of what was initially pulled. you could certainly call myAdapter.Update(myNewTable) but it will no doubt cause problems because the structure has changed. This is of course unless you manually update the commandtext property of the corresponding commands to reflect the structure of the new table. 2. you are incurring an unnecessary performance hit by copying the data from the table that is returned by the adapter into a new table. this will be more of an issue as the amount of data returned increases. so basically, you can do it this way, but i don't really think it's necessary in your situation. my recommendation would be to just pull the data out using the dataadapter, let the user update the data, and use the same dataadapter to update, if possible. If using the same dataadapter isn't possible, then you have to look into how to set the properties of the dataadatper and it's underlying Insert, Update, and Delete Commands and their corresponding CommandText properties to get the data back into the database correctly.


                - jim

                K Offline
                K Offline
                kowplunk
                wrote on last edited by
                #7

                I kinda thought that it might be a problem. I am trying to get a dataGrid style to work, but I can't find a lot on it. This is what I have so far on the methods that links the dataSet and the dataGrid I have created the style through the menus, creating the grid style and all column styles to hide certain columns, but I am having a hard time makig the datagrid use the style. There does not seem to be a lot written on this subject.

                J 1 Reply Last reply
                0
                • K kowplunk

                  I kinda thought that it might be a problem. I am trying to get a dataGrid style to work, but I can't find a lot on it. This is what I have so far on the methods that links the dataSet and the dataGrid I have created the style through the menus, creating the grid style and all column styles to hide certain columns, but I am having a hard time makig the datagrid use the style. There does not seem to be a lot written on this subject.

                  J Offline
                  J Offline
                  Jim Matthews
                  wrote on last edited by
                  #8

                  i had a hard time when first using these as well. the more you use them the easier it gets. i would say first, make sure that all of the mappingname properties for the tablestyle and columnstyles are spelled correctly. tablestyle.mappingname should = datatable.tablename columnstyle.mappingname should = datatable.cols(x).columnname (i.e. the column it should map to) if the grid isn't using the tablestyle at all the most likely culprit would be the tablestyle mappingname property.


                  -jim

                  K 1 Reply Last reply
                  0
                  • J Jim Matthews

                    i had a hard time when first using these as well. the more you use them the easier it gets. i would say first, make sure that all of the mappingname properties for the tablestyle and columnstyles are spelled correctly. tablestyle.mappingname should = datatable.tablename columnstyle.mappingname should = datatable.cols(x).columnname (i.e. the column it should map to) if the grid isn't using the tablestyle at all the most likely culprit would be the tablestyle mappingname property.


                    -jim

                    K Offline
                    K Offline
                    kowplunk
                    wrote on last edited by
                    #9

                    ya it was the tableStyle mapping property, but I was leaving that out because I was trying to set that within the code to allow different functions to display different columns. Is the mapping name mor for assigning different styles to different tables within the datagrid? Because I can't figure out how to do it via code.

                    K 1 Reply Last reply
                    0
                    • K kowplunk

                      ya it was the tableStyle mapping property, but I was leaving that out because I was trying to set that within the code to allow different functions to display different columns. Is the mapping name mor for assigning different styles to different tables within the datagrid? Because I can't figure out how to do it via code.

                      K Offline
                      K Offline
                      kowplunk
                      wrote on last edited by
                      #10

                      ok, I think I am just too tired to think, but I see how to do it now. Disregard that last post.

                      K 1 Reply Last reply
                      0
                      • K kowplunk

                        ok, I think I am just too tired to think, but I see how to do it now. Disregard that last post.

                        K Offline
                        K Offline
                        kowplunk
                        wrote on last edited by
                        #11

                        well I got everything working the way that I want to. Thanks again for the help

                        J 1 Reply Last reply
                        0
                        • K kowplunk

                          well I got everything working the way that I want to. Thanks again for the help

                          J Offline
                          J Offline
                          Jim Matthews
                          wrote on last edited by
                          #12

                          no problem, glad it worked out for ya. sorry for the lack of responsiveness, i had left work and have spent the last few hours playing in the backyard with my daughter... some things are more important you know. :) just in case though, as for the last post, if you just create multiple tablestyles and give them the appropriate mapping name based on the table you want them to display, the grid will take care of handling everything for you. then you can have the parent table display one way (for example: light blue background) a first child table another (light green background) and a second child table a third (orange background) it's pretty flexible. the ony real downside is the maintenance if columnnames change etc. take it easy.


                          -jim

                          K 1 Reply Last reply
                          0
                          • J Jim Matthews

                            no problem, glad it worked out for ya. sorry for the lack of responsiveness, i had left work and have spent the last few hours playing in the backyard with my daughter... some things are more important you know. :) just in case though, as for the last post, if you just create multiple tablestyles and give them the appropriate mapping name based on the table you want them to display, the grid will take care of handling everything for you. then you can have the parent table display one way (for example: light blue background) a first child table another (light green background) and a second child table a third (orange background) it's pretty flexible. the ony real downside is the maintenance if columnnames change etc. take it easy.


                            -jim

                            K Offline
                            K Offline
                            kowplunk
                            wrote on last edited by
                            #13

                            what if you want different table styles pointing to the same table. The app that I am working on is one that is used to correct tests. There is more than one type of error. Right now I have all the data being retrieved and thrown into the same table. I may have to change this is base the query on the correction mode and insert the data into different datatables, I really should do this, but I am still curious of the present problem. I would like to create tablestyles, which I though that I did, so that in the different correction modes different columns are displayed, but I get an error when I try to do this: An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll Additional information: The data grid table styles collection already contains a table style with the same mapping name. Now they are the same mapping name, because the mapping name is the name of the table right? Thanks for the help

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups