5
Answers

Closing database connection in asp.net C# razor syntax

Hello Everyone,
 
I have built a website in asp.net C# webpages with razor syntax. I have used WebMatrix. My database is IBM db2.
 
I have two questions.
 
The first question is : 
 
I have opened a database connection where "client" is my connection string and is stored in my web.config file.
var db = Database.Open(client); 
I would like to know how to close this database connection. 
----------------------------- 
 
The second question is :
 
The website extension is .cshtml
What are the requirements for the .cshtml extension that i need in my webserver in order to deploy it ?
For instance, i have these installed :

IIS 7.0
.Net Framework 4.0
I would be grateful if you could help me with some answers. Thanks in advance.
 
Answers (5)
0
Vulpes

Vulpes

NA 98.3k 1.5m 10y
Assuming all numeric columns are of type double, then try:

   foreach(DataRow dr in table1.Rows)
   {
      string colName = dr["Par Name"].ToString();
      if(table5.Columns.Contains(colName))
      {
         double lower = (double)dr["lower_limit"];
         double upper = (double)dr["upper_limit"];
         double min = table5.Rows.Cast<DataRow>().Min(r => r.Field<double>(colName));
             
         if (min >= lower)
         {
            double max = table5.Rows.Cast<DataRow>().Max(r => r.Field<double>(colName));
            if (max <= upper) table5.Columns.Remove(colName);
         }
      }
   }

or, if they're all strings, try:

   foreach(DataRow dr in table1.Rows)
   {
      string colName = dr["Par Name"].ToString();
      if(table5.Columns.Contains(colName))
      {
         double lower = double.Parse(dr["lower_limit"].ToString());
         double upper = double.Parse(dr["upper_limit"].ToString());
         double min = table5.Rows.Cast<DataRow>().Min(r => double.Parse(r.Field<string>(colName)));
             
         if (min >= lower)
         {
            double max = table5.Rows.Cast<DataRow>().Max(r => double.Parse(r.Field<string>(colName)));
            if (max <= upper) table5.Columns.Remove(colName);
         }
      }
   }

Accepted
0
Farhan Shariff

Farhan Shariff

NA 1.1k 111.4k 10y
Thank you vulpes . works perfect only  thing is I had to remove the last three columns from table5 (Split , Die_id and normal inverse), since I am adding it later again no problem :)
0
Khan Abrar Ahmed

Khan Abrar Ahmed

NA 5.8k 200k 10y
Hi,
what basis u want to match the rows?? please explain little bit more.