none
table adapter schema RRS feed

  • Question

  • Is it possible to use the same table adapter to query 2 different tables with the same schema. Reason being is that I have a database with 2 sets of tables, 1 for plant A and the other for plant B.  In the long run, there will only be 1 database with 1 set of tables but for demo reasons, this what I have to work with.  I haven't een able to find a way to assign the correct table adapter dynamically depending on which plant is being tested but i know that the database tables for each plant have the same schema so theorectically i could use the same tableadapter right?!

    Thanks in advance

    Monday, October 15, 2007 7:37 PM

All replies

  • It might help to see some code. It seems to me that you should be able to dynamically select the table you want to use, but I really don't know how you are building your data sources in code.

     

    Tuesday, October 16, 2007 1:15 PM
  • I used the drag and drop TableAdapter Configuration wizard to setup all of my table adapters by selecting the table from my data source and dragging it into the dataset.  When I do this, the main query (which i guess determines the schema) is set to query that particular table.  I guess what I am trying to do was to add a query to that table adapter but using another table.  I was not sure if that was good practice or not because all the tutorials I am seeing add queries to the adapter all using the table specified when the adapter was originally created.  I wish I could show some code but it is all auto generated. 

    I have tried creating 2 adapters one for each table but i cant seem to get that to work correctly based on which plant i want to test. I want to use the rows of the table but I cant figure out how to dimension/ intialize them.

    Dim sensorAdapter as Object
    Dim sensorTbl as Object

    If plantToTest = "A" Then
    sensorAdapter = New sensorDetails_ATableAdapter
    sensorTbl = New sensorDetails_ADataTable
    Else
    sensorAdapter = New sensorDetails_BTableAdapter
    sensorTbl = New sensorDetails_BDataTable
    End If

    This is where I cant figure out how to do it because I dont know which table I am going to use yet. I tried declaring as Object but that wasnt working.

    Dim sensorRow as  ????
    For each sensorRow in sensorTbl
    .....table code
    Next


    Am I just missing something
    Thanks again

    Tuesday, October 16, 2007 2:09 PM