[vb.net] how to get/find specific data from dgv and output this?-VBForums
Results 1 to 6 of 6

Thread: [vb.net] how to get/find specific data from dgv and output this?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2016
    Posts
    10

    [vb.net] how to get/find specific data from dgv and output this?

    Dear friends,

    Software working with: Visual Basic Express 2013
    What do i want to make? An qoutation which shows the products and services.
    At first, what do i have?
    2 unbounded Dgvs
    An table for products, for services and costumers.
    The qoutation form which got 2 tabs in it, in each tab 1 unbounded dgv for the added products and services.
    But then my problem,
    I want to send these unbounded Dgvs to excel,
    And without any sorting that is working.
    But, in my products i have categories per product

    For example:
    2 t-shirts which got an category clothes
    1 pair of shoes which got an category footwear

    How is it possible to display Those 3 products in excel seperated and sorted per category?
    Such as:
    Clothing
    2x t-shirt

    Footwear
    Shoes

    I hope someone got the answer to this. If more information needed, let me know.

    Gr,

    Jaspertje

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,020

    Re: [vb.net] how to get/find specific data from dgv and output this?

    if you are populating the dgv from a database table, you can do a SQL query on the table then use copyfromrecordset into excel
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2016
    Posts
    10

    Re: [vb.net] how to get/find specific data from dgv and output this?

    Quote Originally Posted by westconn1 View Post
    if you are populating the dgv from a database table, you can do a SQL query on the table then use copyfromrecordset into excel
    Hey Pete,

    yes i'm populating the dgv with an Access Db. So i don't know if SQL is working with that. I've been searching on google for the solution but i couldn't find it.

    Is it possible that the 2 unbounded datagridviews should get bounded with a query made in Access? And than with the copyfromrecordset to excel? Or is that bullsh*t?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,020

    Re: [vb.net] how to get/find specific data from dgv and output this?

    yes you can use SQL to create a sorted and /or criteria based result from the table, then populate the dgv or excel from the recordset

    something like
    Code:
    sql = "select * from tablename order by category"
    rs = dbconnection.openrecordset(sql)
    i never use bound controls, you can search on "why bounded controls are evil" then decide for your self
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2016
    Posts
    10

    Re: [vb.net] how to get/find specific data from dgv and output this?

    Quote Originally Posted by westconn1 View Post
    yes you can use SQL to create a sorted and /or criteria based result from the table, then populate the dgv or excel from the recordset

    something like
    Code:
    sql = "select * from tablename order by category"
    rs = dbconnection.openrecordset(sql)
    i never use bound controls, you can search on "why bounded controls are evil" then decide for your self
    Well ok! I will check that later, thanks for your comments.
    Should catch some sleep now.

  6. #6
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    6,513

    Re: [vb.net] how to get/find specific data from dgv and output this?

    The data binding is evil argument really only applies to VB6. Data binding really was rubbish in VB6 but the worst issues were resolved with .Net, which you are using, so you can now use Databinding with confidence. It's certainly not applicable to every situation but it's a perfectly valid approach for 99% of them.
    You can depend upon the Americans to do the right thing. But only after they have exhausted every other possibility - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.