VB-APP: Datagridview calculated column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • drews1f
    New Member
    • Nov 2008
    • 4

    VB-APP: Datagridview calculated column

    Hello,

    I have been trying for days to add more than one database column into a cell but im not having any luck.

    Here is my code:

    Code:
            Dim mortAdapter As New SqlDataAdapter("(SELECT mort_id,mort_date_written,mort_type,mort_repay_method," & _
            "mort_deal,mort_company,mort_no,mort_amount,mort_comm,mort_settled,mort_actual_comm," & _
            "mort_comm_recd,mort_comm_paid,mort_introducer,mort_completed,mort_application_date,mort_client_id1," & _
            "mort_client_id2, c1.client_name as c1name, c1.client_surname as c1surname, " & _
            "c2.client_name as c2name " & _
            "FROM remortgage " & _
            "LEFT JOIN client c1 ON c1.client_id = mort_client_id1 " & _
            "LEFT JOIN client c2 ON c2.client_id = mort_client_id2 " & _
            "WHERE mort_application_date IS NOT NULL) UNION " & _
            "(SELECT mort_id,mort_date_written,mort_type,mort_repay_method," & _
            "mort_deal,mort_company,mort_no,mort_amount,mort_comm,mort_settled,mort_actual_comm," & _
            "mort_comm_recd,mort_comm_paid,mort_introducer,mort_completed,mort_application_date,mort_client_id1," & _
            "mort_client_id2, c1.client_name as c1name, c1.client_surname as c1surname, " & _
            "c2.client_name as c2name " & _
            "FROM remortgage " & _
            "LEFT JOIN client c1 ON c1.client_id = mort_client_id1 " & _
            "LEFT JOIN client c2 ON c2.client_id = mort_client_id2 " & _
            "WHERE mort_application_date IS NOT NULL)" & _
            " ORDER BY mort_application_date DESC", objConnection)
    i want to add a column with the header 'Client Name(s)'
    and in this column i want to put in:

    c1name c1surname
    c2name c2surname


    is this possible?
  • vanc
    Recognized Expert New Member
    • Mar 2007
    • 211

    #2
    It seems not very hard to do but at least you have to clear up your question first. I don't understand what you want to achieve here.

    Comment

    • drews1f
      New Member
      • Nov 2008
      • 4

      #3
      Originally posted by vanc
      It seems not very hard to do but at least you have to clear up your question first. I don't understand what you want to achieve here.

      OK. when i make my dataset and bind it to datagridview it presents the data like so:

      --
      named columns
      db columns
      actual output
      --

      Date Written | Name | Mortgage Amount | Type | Comm | etc
      mort_applicatio n_date | client_name client_surname | mort_amount | mort_type | mort_comm
      01/01/2001 | Andrew Robins | £212,000 | Fixed Rate | £848


      My problem is at the moment i can only bind 'client_name' to the NAME column
      where i actually want to bind

      client_name AND client_suranme to the Name column.

      Do you understand what i mean?

      Comment

      • drews1f
        New Member
        • Nov 2008
        • 4

        #4
        to be 100% clear. At the moment my datagridview reads like:


        Date Written | Name | Mortgage Amount | Type | Comm | etc
        mort_applicatio n_date | client_name | mort_amount | mort_type | mort_comm
        01/01/2001 | Andrew | £212,000 | Fixed Rate | £848




        when i really want it to look like:



        Date Written | Name | Mortgage Amount | Type | Comm | etc
        mort_applicatio n_date | client_name client_surname | mort_amount | mort_type | mort_comm
        01/01/2001 | Andrew Robins | £212,000 | Fixed Rate | £848

        Comment

        • drews1f
          New Member
          • Nov 2008
          • 4

          #5
          i found some info at this link:
          http://www.informit.co m/articles/article.aspx?p= 446453&seqNum=5

          which i think is what i need except it appears to be c#
          can anyone convert it to vb.net for me ? :)

          thanks

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6


            This is an excellent chart detailing the differences between C# and VB.NET. You should have no problem translating between the two.

            Comment

            Working...