Hello everyone,
I am a beginner in ASP.NET C#.
I am trying to build a dashboard. The database is IBM db2. I am using asp.net webpages to develop it.
Infact, i have several connection string and i am trying to loop through the database name to open each database.
Code :
//declaration of array of database name found in the web.config string[] clients = {"database_name1", "database_name2"};
//database connectionforeach (var client in clients) {
var db = Database.Open(client);
//simple queryvar selectedClient = db.Query("SELECT * FROM DB2INST1.CUSTOMERS FETCH FIRST 1 ROWS ONLY");
}//display query@foreach(var row in selectedClient) {
@row.CUSTOMERNAME
}Compiler Error Message: CS0103: The name 'selectedClient' does not exist in the current context------------------But if i use directly the exact database name without the loop, the same code works.Example :var db = Database.Open("database_name1");
I hope you can help me guys...Thank you
Venkateshwar ReddyPosted Jan 21, 2016, 7:16 AM
//declaration of array of database name found in the web.config//database connection//simple query}ashish sadasingPosted Jan 21, 2016, 8:30 AM