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