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. How to store data from DataGridView to SQL Sever 2005 [modified]

How to store data from DataGridView to SQL Sever 2005 [modified]

Scheduled Pinned Locked Moved Visual Basic
databasehelptutorialquestion
6 Posts 2 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.
  • F Offline
    F Offline
    Francis K Antony
    wrote on last edited by
    #1

    I have DataGridView1 Tool in this DataGridView having 5 columns. Two columns are DataGridViewComboBoxColumn and three columns are DataGridViewTextBoxColumn. My task is two DataGridViewComboBoxColumn1 taken from a data master table1, DataGridViewComboBoxColumn2 is taken from a data master table2 and anther three DataGridViewTextBoxColumn date from user input in the DataGridView1. Now I need All these five columns data’s should be saved in new table called transition table1 Is it passable can you help me?

    Franics K Antony

    modified on Wednesday, August 27, 2008 2:04 AM

    D 1 Reply Last reply
    0
    • F Francis K Antony

      I have DataGridView1 Tool in this DataGridView having 5 columns. Two columns are DataGridViewComboBoxColumn and three columns are DataGridViewTextBoxColumn. My task is two DataGridViewComboBoxColumn1 taken from a data master table1, DataGridViewComboBoxColumn2 is taken from a data master table2 and anther three DataGridViewTextBoxColumn date from user input in the DataGridView1. Now I need All these five columns data’s should be saved in new table called transition table1 Is it passable can you help me?

      Franics K Antony

      modified on Wednesday, August 27, 2008 2:04 AM

      D Offline
      D Offline
      D4ever
      wrote on last edited by
      #2

      Yes it is Possible. Make a For Loop from i=0 to gridview.rows.count-1 insert into transition values('"& ctype(gridview.findcontrol("ComboBox1"),DropDownList).selecteditem.text &"','"& ctype(gridview.findcontrol("ComboBox2"),DropDownList).selecteditem.text &"','"& ctype(gridview.findcontrol("TextBox1"),TextBox).Text &"','"& ctype(gridview.findcontrol("TextBox2"),TextBox).Text &"','"& ctype(gridview.findcontrol("TextBox3"),TextBox).Text &"') Try & if still not working then reply

      Darshana Pathak

      F 1 Reply Last reply
      0
      • D D4ever

        Yes it is Possible. Make a For Loop from i=0 to gridview.rows.count-1 insert into transition values('"& ctype(gridview.findcontrol("ComboBox1"),DropDownList).selecteditem.text &"','"& ctype(gridview.findcontrol("ComboBox2"),DropDownList).selecteditem.text &"','"& ctype(gridview.findcontrol("TextBox1"),TextBox).Text &"','"& ctype(gridview.findcontrol("TextBox2"),TextBox).Text &"','"& ctype(gridview.findcontrol("TextBox3"),TextBox).Text &"') Try & if still not working then reply

        Darshana Pathak

        F Offline
        F Offline
        Francis K Antony
        wrote on last edited by
        #3

        Thank you for you code, But my problem is how to connect more then two table in single DataGridView like a DataGridViewComboBox1 connect one master table1, DataGridViewComboBox2 connect one master table2 at a same time in the two column data’s save in transition table1, How can I do please help me. This is major problem Please mail me it is argent

        Franics K Antony

        D 1 Reply Last reply
        0
        • F Francis K Antony

          Thank you for you code, But my problem is how to connect more then two table in single DataGridView like a DataGridViewComboBox1 connect one master table1, DataGridViewComboBox2 connect one master table2 at a same time in the two column data’s save in transition table1, How can I do please help me. This is major problem Please mail me it is argent

          Franics K Antony

          D Offline
          D Offline
          D4ever
          wrote on last edited by
          #4

          You can bind gridview with query from coding For e.g. dim da as OledbDataAdapter dim dt as new DataTable dim st as String 'Enter Connection String dim cn as OledbConnection("") st="select a.name as Name,b.Address as Address from student a,info b" da=new OledbDataAdapter(st,cn) da.fill(dt) Gridview1.datasource=dt Gridview1.DataBind() and while Adding the ComboBox Column in Gridview You can Give DatatextField= Name & DataValueField= Address Same for ComboBox2 Column Try if Still Not getting then tell so i can give u my phone no so u can call me.

          Darshana Pathak

          F 1 Reply Last reply
          0
          • D D4ever

            You can bind gridview with query from coding For e.g. dim da as OledbDataAdapter dim dt as new DataTable dim st as String 'Enter Connection String dim cn as OledbConnection("") st="select a.name as Name,b.Address as Address from student a,info b" da=new OledbDataAdapter(st,cn) da.fill(dt) Gridview1.datasource=dt Gridview1.DataBind() and while Adding the ComboBox Column in Gridview You can Give DatatextField= Name & DataValueField= Address Same for ComboBox2 Column Try if Still Not getting then tell so i can give u my phone no so u can call me.

            Darshana Pathak

            F Offline
            F Offline
            Francis K Antony
            wrote on last edited by
            #5

            What u said was right, but the problem is In datagridview1 we have 5 columns Column1-slno Column2-specification (combobox) Column3-shape (combobox) Column4-prize Column5-remarks Tables1-t01customerorder Table2-m01specification Table03-m02shape In load event-All above columns are retrieved from transaction table –t01customerorder If we click new button column2 as get data from Table2-m01specification And column3 as to get data from Table03-m01shape, after selecting the value from master table Column1, column4, column5 –user input Click save button, selected data from master table and user input get saved into Tables1-t01customerorder Please help me to achieve task Thank you one’s again

            Franics K Antony

            D 1 Reply Last reply
            0
            • F Francis K Antony

              What u said was right, but the problem is In datagridview1 we have 5 columns Column1-slno Column2-specification (combobox) Column3-shape (combobox) Column4-prize Column5-remarks Tables1-t01customerorder Table2-m01specification Table03-m02shape In load event-All above columns are retrieved from transaction table –t01customerorder If we click new button column2 as get data from Table2-m01specification And column3 as to get data from Table03-m01shape, after selecting the value from master table Column1, column4, column5 –user input Click save button, selected data from master table and user input get saved into Tables1-t01customerorder Please help me to achieve task Thank you one’s again

              Franics K Antony

              D Offline
              D Offline
              D4ever
              wrote on last edited by
              #6

              can u tell me that upto which point ur successfully getting the results? reply so i can give u further hint

              Darshana Pathak

              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