Question

datagrid view insert data

Asked by: demoniumz

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

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-04-16 at 15:10:53ID24330049
Topics

VB Controls

,

Visual Basic Programming

,

Microsoft Access Database

,

VB Script

,

Visual Studio

Participating Experts
1
Points
500
Comments
42

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. combobox in a vb.net datagrid
    Is there any way to display a combobox in datagrid column in VB.Net. (I found column style property can be set only to textbox or check box. ) Please Help me!!! -Kannam
  2. combobox in DataGrid
    Hi, I am trying to put a combobox in a datagrid which is supposed to be inserted using DataGridColumnStyle Class. But i am not able to get how do you exactly use it. Can anyone please help me? Regards, Arpan *** Email address removed by RoverM, EE Page Editor .NET ***
  3. VB.Net ComboBox in a Datagrid
    I need to place a combobox into my datagrid. The values in the combobox will come from a dataset "Table XcomList" The datagrid will be bound to Table BigData the value selected in the combobox should be placed in the dataset Bigdata.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: jpaulinoPosted on 2009-04-16 at 15:48:27ID: 24163523

Does the datagridview are bound to something ?

 

by: demoniumzPosted on 2009-04-17 at 09:29:11ID: 24169498

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

 

by: demoniumzPosted on 2009-04-18 at 01:17:27ID: 24174392

Jpaulino can u help?

 

by: demoniumzPosted on 2009-04-19 at 11:05:12ID: 24179973

hello anyone to help

 

by: jpaulinoPosted on 2009-04-19 at 11:41:47ID: 24180105

Sorry, let my try to look at this later.

 

by: demoniumzPosted on 2009-04-19 at 12:32:50ID: 24180263

ok

 

by: demoniumzPosted on 2009-04-19 at 16:01:04ID: 24181006

ok i wait thnks for help

 

by: jpaulinoPosted on 2009-04-20 at 02:12:35ID: 24182904

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

 

by: demoniumzPosted on 2009-04-20 at 09:49:55ID: 24186298

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

 

by: demoniumzPosted on 2009-04-20 at 11:07:26ID: 24187066

so j paulino

 

by: demoniumzPosted on 2009-04-20 at 12:14:03ID: 24187678

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




 

by: jpaulinoPosted on 2009-04-20 at 13:43:08ID: 24188503

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-exchange.com/Programming/Languages/.NET/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 ?

 

by: jpaulinoPosted on 2009-04-20 at 13:53:15ID: 24188595

 

by: demoniumzPosted on 2009-04-20 at 14:10:00ID: 24188746

what about the text boxes

 

by: demoniumzPosted on 2009-04-20 at 14:36:50ID: 24188987

JPAULINO what code  you need to provide you in order to  help

 

by: demoniumzPosted on 2009-04-20 at 15:24:08ID: 24189324

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

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

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:

Select allOpen in new window

 

by: jpaulinoPosted on 2009-04-20 at 15:25:57ID: 24189338

You want to fill the textboxes with the information from the selected item ?

Two very easy examples that I already posted:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23748735.html

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23750187.html

Sorry man ... i'm a little busy in this days but I will try to help you more.

 

by: jpaulinoPosted on 2009-04-20 at 15:28:09ID: 24189352

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.

 

by: demoniumzPosted on 2009-04-20 at 16:23:42ID: 24189643

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)).AutoIncrement = 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.Add("Text", mBS, "Id", True)
        Me.TextBox2.DataBindings.Add("Text", mBS, "Item", True)
        Me.TextBox3.DataBindings.Add("Text", mBS, "Date", True)
 
        ' Populates the datagridview
        Me.DataGridView1.DataSource = mBS
    End Sub
 
End Class

 

by: jpaulinoPosted on 2009-04-21 at 00:00:56ID: 24191531

demoniumz,

You have to change somethings and not just copy/paste.

Can you upload what you have ? (the project)

 

by: demoniumzPosted on 2009-04-21 at 01:40:11ID: 24192063

where to  upload it?

 

by: demoniumzPosted on 2009-04-21 at 02:02:27ID: 24192155

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

 

by: jpaulinoPosted on 2009-04-21 at 02:25:44ID: 24192304

Ok, now explain what's the problem, now that i can see the foms/code ?

 

by: demoniumzPosted on 2009-04-21 at 02:57:05ID: 24192474

ok  here explain  

 

by: jpaulinoPosted on 2009-04-21 at 03:33:27ID: 24192708

Remove the combobocolumn and add a new one "textboxcolumn" for the item ProductID

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)

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

 

by: demoniumzPosted on 2009-04-21 at 03:34:03ID: 24192710

ok you understand what i want to do?

 

by: jpaulinoPosted on 2009-04-21 at 03:36:23ID: 24192718

Opps, wrong version

       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)

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

 

by: demoniumzPosted on 2009-04-21 at 03:39:46ID: 24192737

where i must add these?

 

by: jpaulinoPosted on 2009-04-21 at 03:42:44ID: 24192749

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

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:

Select allOpen in new window

 

by: demoniumzPosted on 2009-04-21 at 03:49:45ID: 24192799

you try and is working?

 

by: jpaulinoPosted on 2009-04-21 at 03:51:19ID: 24192812

Yep!

Have you done this:

Remove the combobocolumn and add a new one "textboxcolumn" for the item ProductID

 

by: demoniumzPosted on 2009-04-21 at 04:04:30ID: 24192912

can u  upload me back the project i  sent u  with corection i get error

 

by: demoniumzPosted on 2009-04-21 at 04:15:05ID: 24192985

jpaulino can u  upload me back the project i  sent u  with corection i get error

 

by: jpaulinoPosted on 2009-04-21 at 04:15:21ID: 24192987

No, I needed to convert to 2008. What error do you have and do you have the datagridview like this:

 

by: demoniumzPosted on 2009-04-21 at 04:26:38ID: 24193049

working but i need to edit Product name in  datagrid navigator  that is take from the producsbinding source can u  explain me  how >?

 

by: demoniumzPosted on 2009-04-21 at 04:39:37ID: 24193134

can u explain me  about these

 

by: demoniumzPosted on 2009-04-21 at 05:00:38ID: 31571239

excelent

 

by: jpaulinoPosted on 2009-04-21 at 05:07:11ID: 24193325

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 ?

 

by: demoniumzPosted on 2009-04-21 at 05:31:19ID: 24193491

the product id in the datagrid view  is display Numbers
not name  that is the problem

 

by: demoniumzPosted on 2009-04-21 at 05:57:48ID: 24193717

anew question is open  jpaulino can  u post there

 

by: demoniumzPosted on 2009-04-23 at 23:51:52ID: 24222352

japaulino i know  that the question is closed by i need help again pls

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...