hi,
i have list of database name in drop down list, when i choose database i want the related table to be display in grid.?
how can i do this?how to set connection string for this?
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
ORDER BY TABLE_NAME
using this code i can display all tables in a particular databse in SQL quey analyser, it displays all tables from selected database in toolbar
but in my coding part
server=localhost;Trusted_Connection=true;database=Reports...
this is my connection string ...but it refers to only reports database,so the query will dispaly all table in reports DB.but i need to dispaly table for selected database in DDL.how cxan i set connection str then?or how can i write query to pass database name also in where clause?
Thanks for any help
You can set the value of the drop down list items to be the connection string to be used itself for the respective database. When the user changes the selection in the drop down list, you can put the code in the selected index change event of the drop down list and you can get the value of the currently selected item which will be the connection string to be used. Pass the value (i.e., the connection string) in another method and at the time of creating the connection object use that variable as the connection string. Feel free to ask about any queries for this approach.
Hope this helps.
No comments:
Post a Comment