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. C#
  4. DataGrid

DataGrid

Scheduled Pinned Locked Moved C#
questiondatabase
8 Posts 5 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.
  • M Offline
    M Offline
    Mazdak
    wrote on last edited by
    #1

    I want to use database in connected mode with DataReader.After I use ExecuteReader() I waana fill DataGrid with it but I can't add row to DataGrid dynamicly or show the table in DataGrid in Connected mode.

    OleDbCommand command = new OleDbCommand ( "select * from Tennis", this.myoleDbConnection );

    myoleDbConnection.Open ();

    OleDbDataReader reader = command.ExecuteReader ( );

    while ( reader.Read () )
    {
    //How can I fill DataGrid?????
    }
    reader.Close ();
    myoleDbConnection.Close ();

    Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

    J C 2 Replies Last reply
    0
    • M Mazdak

      I want to use database in connected mode with DataReader.After I use ExecuteReader() I waana fill DataGrid with it but I can't add row to DataGrid dynamicly or show the table in DataGrid in Connected mode.

      OleDbCommand command = new OleDbCommand ( "select * from Tennis", this.myoleDbConnection );

      myoleDbConnection.Open ();

      OleDbDataReader reader = command.ExecuteReader ( );

      while ( reader.Read () )
      {
      //How can I fill DataGrid?????
      }
      reader.Close ();
      myoleDbConnection.Close ();

      Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      I don't think you can fill the datagrid directly, you have to use a datatable at the very least. James Simplicity Rules!

      M 1 Reply Last reply
      0
      • J James T Johnson

        I don't think you can fill the datagrid directly, you have to use a datatable at the very least. James Simplicity Rules!

        M Offline
        M Offline
        Mazdak
        wrote on last edited by
        #3

        Yes,thats the thing I find out today,So I think when I want use DataReader it is not good idea to use DataGrid and ListView is better option for it.Beacaue for DataGrid I have to use DataSet or DataTable so I have to do one extra operation.Whats your opinion about it? Thanks :) Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

        S 1 Reply Last reply
        0
        • M Mazdak

          Yes,thats the thing I find out today,So I think when I want use DataReader it is not good idea to use DataGrid and ListView is better option for it.Beacaue for DataGrid I have to use DataSet or DataTable so I have to do one extra operation.Whats your opinion about it? Thanks :) Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

          S Offline
          S Offline
          SimonS
          wrote on last edited by
          #4

          [my 2 cents] Using a listview is a far better option. Short of prototyping, I don't see a place for large scale databinding in applications. Cheers, Simon "I get paid for my brain and my thinking in several obscure worlds", Olli, The Lounge

          A 1 Reply Last reply
          0
          • S SimonS

            [my 2 cents] Using a listview is a far better option. Short of prototyping, I don't see a place for large scale databinding in applications. Cheers, Simon "I get paid for my brain and my thinking in several obscure worlds", Olli, The Lounge

            A Offline
            A Offline
            Andres Manggini
            wrote on last edited by
            #5

            [my 2 cents too] I understand this using the old databinding control (see VB 6 controls), but with the new ADO.NET model I think things have changed, the combination of Connection, DataAdapter, DataSet and DataGrid should work a lot better. Anyway, I haven't done any testing yet. Andres Manggini. Buenos Aires - Argentina.

            J 1 Reply Last reply
            0
            • A Andres Manggini

              [my 2 cents too] I understand this using the old databinding control (see VB 6 controls), but with the new ADO.NET model I think things have changed, the combination of Connection, DataAdapter, DataSet and DataGrid should work a lot better. Anyway, I haven't done any testing yet. Andres Manggini. Buenos Aires - Argentina.

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #6

              Correct, the VB6 controls sucked because they always kept a connect to the database open, so you could count on there being x number of connections at any one time. With the .NET model you open a connection, get the data, then close the connection; everything is operated on in a disconnected state. Once you're done editing you can ignore the changes or open another connection and make the changes. James Simplicity Rules!

              1 Reply Last reply
              0
              • M Mazdak

                I want to use database in connected mode with DataReader.After I use ExecuteReader() I waana fill DataGrid with it but I can't add row to DataGrid dynamicly or show the table in DataGrid in Connected mode.

                OleDbCommand command = new OleDbCommand ( "select * from Tennis", this.myoleDbConnection );

                myoleDbConnection.Open ();

                OleDbDataReader reader = command.ExecuteReader ( );

                while ( reader.Read () )
                {
                //How can I fill DataGrid?????
                }
                reader.Close ();
                myoleDbConnection.Close ();

                Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

                C Offline
                C Offline
                Carlos Antollini
                wrote on last edited by
                #7

                You need to use a datactrl, then assign the datagrid to datacontrol and in your code asign the dataset to datactrl Best Regards Carlos Antollini. Sonork ID 100.10529 cantollini

                M 1 Reply Last reply
                0
                • C Carlos Antollini

                  You need to use a datactrl, then assign the datagrid to datacontrol and in your code asign the dataset to datactrl Best Regards Carlos Antollini. Sonork ID 100.10529 cantollini

                  M Offline
                  M Offline
                  Mazdak
                  wrote on last edited by
                  #8

                  DataSet work in disconnected mode,I wanna use connected mode.:) Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

                  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