how to use database containing the name of anothe database...

Discussion in 'C#' started by bhuppi890109, Sep 24, 2010.

  1. #1
    hi friends.... i am creating a new website in ASP.NET...i have 4 tables in database......test1,test2,test3,testnames...and testnames contain one column "tno" which contain entry as test1,test2 and test3(the name of another tables). and it also contain table of names of tests(related to test1,test2,test3)..now i want to show the table name on one page and on clicking on this name the nest page should shows the data into table related to that name(test1,test2,test3)...
    ...i have a query ..
    select * from test1
    but i want that it should pick the table name(test1,test2,test3) from table testnames on clicking the name....

    i hope question is clear, if not you can ask me
     
    bhuppi890109, Sep 24, 2010 IP
  2. Calciu Sorin

    Calciu Sorin Member

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #2
    No, your question is not clear
    What are you trying to achieve ?
    Why would you want to store tables name in database ?

    Your problem must be solved using unique IDs, i guess
    Read more about relationships between database tables
     
    Calciu Sorin, Oct 2, 2010 IP
  3. longcall911

    longcall911 Peon

    Messages:
    1,672
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The link that the user clicks should be created with a querystring (e.g. nextpage.aspx?cnt=table1).

    On nextpage, get the value of cnt (whichin this case is table1) and get the data for table1 in the page_load event.
     
    longcall911, Oct 11, 2010 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Or using querystrings just add a parameter to a sqldatasource control and bind it to the relevant control

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString = "<%$ ConnectionStrings:ConnectionString" %>"
        SelectCommand = "Select * from @TableName;">
        <SelectParameters>
            <asp:QueryStringParameter Name="TableName" QueryStringField="cnt" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    
    PHP:
     
    AstarothSolutions, Oct 14, 2010 IP