Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Problem with Access

Problem with Access

Scheduled Pinned Locked Moved Database
databasehelpcsharpvisual-studioxml
6 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JackMisani
    wrote on last edited by
    #1

    Hello everybody, i'm writing here because i'm really becoming crazy, i read every kind of internet pages but I'm not able to find a solution but i'm also sure that the solution is behind the corner. I have an Access database with different tables. The main table has different foreign keys to other tables. I do an example with 2 tables to make the problem easier: Table Products Field1 - Primary Key: Product Code - text Field2: Description - text Field3: Product Type - integer Table ProductTypes Field1: Primary Key - ID - integer - FK on Field3 of "Table Product" Field2: Description - Text Now, I open Visual Studio, I add my database and I drag&drop the table "Product" on my Windows Form as a DatagridView. The wizard create for me, the tableAdapter, bindinsource ecc.... If I start my app the DatagridView is populate with the correct data but in the column "Product Type" I see the number from the PK of the table "ProductTypes" while I'd like to see the Description. I created a new TableAdapter query that give me the result i want to see but when I confirm I get the message that i'm created a query that give a different result from the original schema. If I continue the query is created but i'm not able to retrieve data using this new query. THe only way I've to retrieve datas as I want is to modify the original Fill query but in this case the relation between the 2 tables will be removed and also the TableAdapter Insert method will be removed. So, I will see the data in datagridview as i'd like to see but I don't have anymore the insert method. Can someone help me by telling I could I retrieve the data in the way I desider without losing the chance to insert new record in the table? Thanks Giacomo

    T 1 Reply Last reply
    0
    • J JackMisani

      Hello everybody, i'm writing here because i'm really becoming crazy, i read every kind of internet pages but I'm not able to find a solution but i'm also sure that the solution is behind the corner. I have an Access database with different tables. The main table has different foreign keys to other tables. I do an example with 2 tables to make the problem easier: Table Products Field1 - Primary Key: Product Code - text Field2: Description - text Field3: Product Type - integer Table ProductTypes Field1: Primary Key - ID - integer - FK on Field3 of "Table Product" Field2: Description - Text Now, I open Visual Studio, I add my database and I drag&drop the table "Product" on my Windows Form as a DatagridView. The wizard create for me, the tableAdapter, bindinsource ecc.... If I start my app the DatagridView is populate with the correct data but in the column "Product Type" I see the number from the PK of the table "ProductTypes" while I'd like to see the Description. I created a new TableAdapter query that give me the result i want to see but when I confirm I get the message that i'm created a query that give a different result from the original schema. If I continue the query is created but i'm not able to retrieve data using this new query. THe only way I've to retrieve datas as I want is to modify the original Fill query but in this case the relation between the 2 tables will be removed and also the TableAdapter Insert method will be removed. So, I will see the data in datagridview as i'd like to see but I don't have anymore the insert method. Can someone help me by telling I could I retrieve the data in the way I desider without losing the chance to insert new record in the table? Thanks Giacomo

      T Offline
      T Offline
      Tim Carmichael
      wrote on last edited by
      #2

      Can you create a view in Access and use the view?

      J 1 Reply Last reply
      0
      • T Tim Carmichael

        Can you create a view in Access and use the view?

        J Offline
        J Offline
        JackMisani
        wrote on last edited by
        #3

        Yes, I already did it. I created a View in Access and then I imported it in my Dataset. In this way I'm able to show the correct data in my DataGridView but the Wizard didn't create for me the Insert, Delete and Update method. Do you think I could be able to update the Access database through the view?

        T 1 Reply Last reply
        0
        • J JackMisani

          Yes, I already did it. I created a View in Access and then I imported it in my Dataset. In this way I'm able to show the correct data in my DataGridView but the Wizard didn't create for me the Insert, Delete and Update method. Do you think I could be able to update the Access database through the view?

          T Offline
          T Offline
          Tim Carmichael
          wrote on last edited by
          #4

          A view will only let you see the data. It has been so long since I used Access I can't help you on the inserts, updates, deletes.

          J 1 Reply Last reply
          0
          • T Tim Carmichael

            A view will only let you see the data. It has been so long since I used Access I can't help you on the inserts, updates, deletes.

            J Offline
            J Offline
            JackMisani
            wrote on last edited by
            #5

            I think to have solved the problem....maybe I'm using a bad solution but the result is good. In my dataset I have the Main table that is filled with the original database records. In the same datased I inserted a second table that is filled with a my personal Fill query. In my form I have inserted both table adapter. The first one is only in background while the second one is shown in datagridview. I insert, delete and modify the records one the datagrid and when I click "Save", I reflect the changes in the background table adapter.... Thank Giacomo

            T 1 Reply Last reply
            0
            • J JackMisani

              I think to have solved the problem....maybe I'm using a bad solution but the result is good. In my dataset I have the Main table that is filled with the original database records. In the same datased I inserted a second table that is filled with a my personal Fill query. In my form I have inserted both table adapter. The first one is only in background while the second one is shown in datagridview. I insert, delete and modify the records one the datagrid and when I click "Save", I reflect the changes in the background table adapter.... Thank Giacomo

              T Offline
              T Offline
              Tim Carmichael
              wrote on last edited by
              #6

              Sometimes, we use an 'ugly' solution until we find a 'nice' one. But, results matter.. if it works, great!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups