demoniumz
asked on
datagrid view insert data
hi i have 1 combobox and three textbox i want these fiels to insert it in a datagrid view.HOw i can ihser data on it.I am using vb 2005 linked frommms acess 2003
Does the datagridview are bound to something ?
ASKER
the datagrid is bound to product table but is easy to unbound it.The all problem i have 1 combobox 3 textboxes
i have 1 datagrid view and need to enter the information from the combobox and the 3 textboxes in to the datagrid view.The second small problem that related to datagrid view is one of the textbox called quantity because the data of the combobox and the textbox is bounded to products table and for each product the quantity is very high lets say 50 maybe i need to edit 200 this thing is change the data in the table.what i count do?Add another quantity field maybe OrderQuantity or is any solution for these
sorry if i tired you but i am new to vb 2005
Thns
i have 1 datagrid view and need to enter the information from the combobox and the 3 textboxes in to the datagrid view.The second small problem that related to datagrid view is one of the textbox called quantity because the data of the combobox and the textbox is bounded to products table and for each product the quantity is very high lets say 50 maybe i need to edit 200 this thing is change the data in the table.what i count do?Add another quantity field maybe OrderQuantity or is any solution for these
sorry if i tired you but i am new to vb 2005
Thns
ASKER
Jpaulino can u help?
ASKER
hello anyone to help
Sorry, let my try to look at this later.
ASKER
ok
ASKER
ok i wait thnks for help
i have 1 datagrid view and need to enter the information from the combobox and the 3 textboxes in to the datagrid view.
To enter where ? In the database ?
The second small problem that related to datagrid view is one of the textbox called quantity because the data of the combobox and the textbox is bounded to products table and for each product the quantity is very high lets say 50 maybe i need to edit 200 this thing is change the data in the table.what i count do?Add another quantity field maybe OrderQuantity or is any solution for these
Don't understand this ... what's the problem of change the value
To enter where ? In the database ?
The second small problem that related to datagrid view is one of the textbox called quantity because the data of the combobox and the textbox is bounded to products table and for each product the quantity is very high lets say 50 maybe i need to edit 200 this thing is change the data in the table.what i count do?Add another quantity field maybe OrderQuantity or is any solution for these
Don't understand this ... what's the problem of change the value
ASKER
yes to enter it save it in database.3 textboxes one combobox to add to datagrdi view with a button.The datagr\id view is bound but easy unbound
ASKER
so j paulino
ASKER
The all problem is i have a button a datagrid view related to a table 3 text boxes and one combobox.What i want pass the data from the text boxes and from the combobox to the datagrid row.Using the button.
What is the dificulty to these problem and no one help
Using vb 2005 linked from ms access 2003 and using bindin navigator
What is the dificulty to these problem and no one help
Using vb 2005 linked from ms access 2003 and using bindin navigator
If you have a bound datagridview, you just need to add an extra combocolumn. When you change that column, you can see in here how to detect the combobox selection change http://www.experts-exchang e.com/Prog ramming/La nguages/.N ET/Visual_ Basic.NET/ Q_23805212 .html, you just have to update the cell you need in the same row.
It's not easy to do, it's difficult do explain it all without to have code from you side or an example.
Can you upload an example ?
It's not easy to do, it's difficult do explain it all without to have code from you side or an example.
Can you upload an example ?
Try something like this to fill and update:
https://www.experts-exchange.com/questions/23292122/Write-data-from-DataTable-to-MS-Access-database.html
https://www.experts-exchange.com/questions/23292122/Write-data-from-DataTable-to-MS-Access-database.html
ASKER
what about the text boxes
ASKER
JPAULINO what code you need to provide you in order to help
ASKER
hello i have find the code from an aplication but is chaotic for me is using what i want a button a datrid view and textboxes can someone help me to make it work/
Using ms access 2003 with vb 2005
Table orderdetails the datagrid is bount to orderdetails
tnks i provide more info if needed
Using ms access 2003 with vb 2005
Table orderdetails the datagrid is bount to orderdetails
tnks i provide more info if needed
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
' write data into disk
Dim cmd As New OleDbCommand()
Dim trans As OleDbTransaction
Try
trans = con.BeginTransaction
cmd.CommandText = "insert into order_master(orderno,orderdate,orderstatus,custno,ordervalue,requireddate) values(?,sysdate,'rcvd',?,?,?)"
cmd.Connection = con
cmd.Transaction = trans
cmd.Parameters.Add("orderno", OleDbType.Integer).Value = txtOrdno.Text
cmd.Parameters.Add("custno", OleDbType.Integer).Value = txtCustno.Text
cmd.Parameters.Add("ordervalue", OleDbType.Integer).Value = txtOrderValue.Text
cmd.Parameters.Add("orderdate", OleDbType.VarChar, 10).Value = dtpRequiredDate.Text
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
cmd.CommandText = "insert into order_details values (?,?,?,?)"
cmd.Parameters.Add("orderno", OleDbType.Integer).Value = txtOrdno.Text
cmd.Parameters.Add("mcode", OleDbType.VarChar, 20)
cmd.Parameters.Add("qty", OleDbType.Integer)
cmd.Parameters.Add("value", OleDbType.Integer)
Dim row As DataRow
For Each row In itemstable.Rows
cmd.Parameters(1).Value = row.Item("itemcode").ToString().Split(",")(0)
cmd.Parameters(2).Value = row.Item("qty")
cmd.Parameters(3).Value = row.Item("value")
cmd.ExecuteNonQuery()
Next
' insert into order_tracking table
cmd.Parameters.Clear()
cmd.CommandText = "insert into order_tracking values(?,'rcvd',sysdate)"
cmd.Parameters.Add("ordno", OleDbType.VarChar, 10).Value = txtOrdno.Text
cmd.ExecuteNonQuery()
trans.Commit()
MsgBox("Order Added Successfully")
ClearOrder()
Catch ex As Exception
trans.Rollback()
MsgBox(ex.Message, , "Error")
End Try
End Sub
You want to fill the textboxes with the information from the selected item ?
Two very easy examples that I already posted:
https://www.experts-exchange.com/questions/23748735/Binding-DataGridView-to-TextBoxes-Programmatically.html
https://www.experts-exchange.com/questions/23750187/Questions-regarding-BindingSource.html
Sorry man ... i'm a little busy in this days but I will try to help you more.
Two very easy examples that I already posted:
https://www.experts-exchange.com/questions/23748735/Binding-DataGridView-to-TextBoxes-Programmatically.html
https://www.experts-exchange.com/questions/23750187/Questions-regarding-BindingSource.html
Sorry man ... i'm a little busy in this days but I will try to help you more.
Hey just saw you code snippet ... you don't need all that.
Use the example I have showed to fill and save the datagridview. It's very easy to implement and then you just have to add a datagridviewcomboboxcolumn and when you change it you will update the correct cell in the current row.
Use the example I have showed to fill and save the datagridview. It's very easy to implement and then you just have to add a datagridviewcomboboxcolumn
ASKER
Private mBS As New BindingSource()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Creates a demo table ((TABLE IS ALREADY DO BOUND TO ORDER DETAILS TABLE
Dim dt As New DataTable()
dt.Columns.Add("ID", GetType(Integer)).AutoIncr ement = True
dt.Columns.Add("Item", GetType(String))
dt.Columns.Add("Date", GetType(Date))
' Adds some rows (ROWS ARE ALLREADY THERE )
For i As Integer = 0 To 19
dt.Rows.Add(New Object() {Nothing, "Item " & i, Now.AddDays(i)})
Next
' Binds the fields (NOT WORKING for me ")
mBS.DataSource = dt
Me.TextBox1.DataBindings.A dd("Text", mBS, "Id", True)
Me.TextBox2.DataBindings.A dd("Text", mBS, "Item", True)
Me.TextBox3.DataBindings.A dd("Text", mBS, "Date", True)
' Populates the datagridview
Me.DataGridView1.DataSourc e = mBS
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Creates a demo table ((TABLE IS ALREADY DO BOUND TO ORDER DETAILS TABLE
Dim dt As New DataTable()
dt.Columns.Add("ID", GetType(Integer)).AutoIncr
dt.Columns.Add("Item", GetType(String))
dt.Columns.Add("Date", GetType(Date))
' Adds some rows (ROWS ARE ALLREADY THERE )
For i As Integer = 0 To 19
dt.Rows.Add(New Object() {Nothing, "Item " & i, Now.AddDays(i)})
Next
' Binds the fields (NOT WORKING for me ")
mBS.DataSource = dt
Me.TextBox1.DataBindings.A
Me.TextBox2.DataBindings.A
Me.TextBox3.DataBindings.A
' Populates the datagridview
Me.DataGridView1.DataSourc
End Sub
End Class
demoniumz,
You have to change somethings and not just copy/paste.
Can you upload what you have ? (the project)
You have to change somethings and not just copy/paste.
Can you upload what you have ? (the project)
ASKER
where to upload it?
ASKER
i upload it few seconds is not all the projectbut two forms that is needed products and orders:) the Desktop zip contanins all the data you need thnks;)
http://rapidshare.com/files/223917539/Desktop.rar.html
http://rapidshare.com/files/223917539/Desktop.rar.html
Ok, now explain what's the problem, now that i can see the foms/code ?
ASKER
ok here explain
untitled.PNG
untitled.PNG
Remove the combobocolumn and add a new one "textboxcolumn" for the item ProductID
Then use this for button 2:
Then use this for button 2:
Dim bsource As BindingSource = Me.OrdersDetailsDataGridView.DataSource
Dim ds As DataSet = DirectCast(bsource.DataSource, DataSet)
Dim dr As DataRow = ds.Tables("OrdersDetails").NewRow
dr("OrderID") = 3
dr("ProductID") = 3
dr("UnitPrice") = 4
dr("Quantity") = 4
ds.Tables("OrdersDetails").Rows.Add(dr)
ASKER
ok you understand what i want to do?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
where i must add these?
Where did you asked ?
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim bsource As BindingSource = Me.OrdersDetailsDataGridView.DataSource
Dim ds As DataSet = DirectCast(bsource.DataSource, DataSet)
Dim dr As DataRow = ds.Tables("OrdersDetails").NewRow
dr("OrderID") = OrderIDTextBox.Text
dr("ProductID") = ProductIDComboBox.SelectedValue
dr("UnitPrice") = UnitPriceTextBox.Text
dr("Quantity") = QuantityTextBox.Text
ds.Tables("OrdersDetails").Rows.Add(dr)
End Sub
ASKER
you try and is working?
Yep!
Have you done this:
Remove the combobocolumn and add a new one "textboxcolumn" for the item ProductID
Have you done this:
Remove the combobocolumn and add a new one "textboxcolumn" for the item ProductID
ASKER
can u upload me back the project i sent u with corection i get error
ASKER
jpaulino can u upload me back the project i sent u with corection i get error
No, I needed to convert to 2008. What error do you have and do you have the datagridview like this:
ee.png
ee.png
ASKER
working but i need to edit Product name in datagrid navigator that is take from the producsbinding source can u explain me how >?
ASKER
can u explain me about these
ASKER
excelent
working but i need to edit Product name in datagrid navigator that is take from the producsbinding source can u explain me how >?
But you already have the combo with the name.s You need to change ?
But you already have the combo with the name.s You need to change ?
ASKER
the product id in the datagrid view is display Numbers
not name that is the problem
not name that is the problem
ASKER
anew question is open jpaulino can u post there
ASKER
japaulino i know that the question is closed by i need help again pls