Count records using LINQ

I need to get the number of Tasks in a project for the MaxValue property of Telerik ProgressBar and the numbers of completed tasks for its Value property. Below are the codes I used:

Public Sub progressBar()
Dim projectID As String = Me.txtID.Text
Dim db As New ProjectsEntities()
Dim totalTasks = Aggregate task In db.tblTasks
Where task.ProjectID = projectID
Into Count()
Dim totalTasksCompleted = Aggregate task In db.tblTasks
Where task.ProjectID = projectID And 
task.TaskStatus = "Completed"
Into Count()
Me.TaskProgressBar.Value = totalTasksCompleted
Me.TaskProgressBar.MaxValue = totalTasks
Me.TaskProgressBar.ChunksCount = totalTasks
End Sub

For Average and Sum, below are codes copied from Microsoft Site.

Dim averageOrderCount = Aggregate cust In db.Customers
                        Where cust.City = "London"
                        Into Average(cust.Orders.Count)
msg &= "Average number of Orders per customer: " &
       averageOrderCount & vbCrLf

Dim venezuelaTotalOrders = Aggregate cust In db.Customers
                           Where cust.Country = "Venezuela"
                           Into Sum(cust.Orders.Count)
msg &= "Total number of orders from Customers in 
       Venezuela: " & venezuelaTotalOrders & vbCrLf

MsgBox(msg)

Dim averageCustomersByCity = From cust In db.Customers
                             Group By cust.City
                             Into Average(cust.Orders.Count)
                             Order By Average

Could Not Find Database Engine Startup Handle Error

My fresh installation of MS SQLSERVER 2014 in Windows Server 2012 was not successful due to the error mentioned in the title of this post. Its resolution is presented below:

  1. I remove the SQLSERVER 2014 installation using the Control Panel ->Programs -> Uninstall Program.
  2. I did a fresh install by running the Setup as an Administrator.
  3. In the Server Configuration page after launching the setup and providing necessary details, I used NT Authority\SYSTEM  as startup account for Database Engine services.

Stylesheet not working on pages from other folders

I used a master on pages of my ASP.NET application. CSS and Script files were used in the master using a reference lines as:

<link rel="stylesheet" href="css/style.css" runat="server" />
<script src="js/jquery.min.js"></script>

It works on pages on same root where the CSS and Script folders are located but it never worked in another pages which are located in other folders. I resolved this issue by changing the references as follows:

<link rel="stylesheet" href="~/css/style.css" runat="server" />
<script src=’<%# ResolveUrl("~/js/jquery.min.js")%>’ type="text/javascript"></script>

There’s a line in script that I changed as well to ensure that the file is linked correctly.

 

How to run aspnet_regsql

Personally,  I prefer to use the wizard in running the executable file.

Just locate the file from C:\Windows\Microsoft.NET\Framework\[framework version]\aspnet_regsql.exe) and run the file as Administrator. Provide information as required by the wizard.

Changing the data source of Form Authentication

I created my web application using the Web Form template in VS 2013. It was a quick installation setup where sample pages and the login module were already included.
The login uses the Default connection string which is sourced on the created .mdf file located the App_Data folder. It worked well without extra coding and configuration.
A week later, I decided to change my data source so that I can use my SQL Server membership database. It is not so complicated, just need to know where to do the changes in the application. Below are the steps I did:

1. Change the connection string in the web.config file from

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;
AttachDbFilename=|DataDirectory|\aspnet-MindwebUniversity-20141127075146.mdf;Initial 
Catalog=aspnet-MindwebUniversity-20141127075146;Integrated Security=True"
 providerName="System.Data.SqlClient" />

to

<add name="ApplicationServices" connectionString="Data Source=Mindweb;Initial Catalog=MindwebUniversity; Persist Security Info=True; User ID=Username;Password=1234" providerName="System.Data.SqlClient"/>

2. Provide values on the Membership, Providers and Role Managers sections

  <membership>
 <providers>
 <clear/>
 <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
 </providers>
 </membership>
 <profile>
 <providers>
 <clear/>
 <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
 </providers>
 </profile>
 <roleManager enabled="true">
 <providers>
 <clear/>
 <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
 <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>
 </providers>
 </roleManager>

3. View the project properties and ensure to change the value in the fields as shown in the image below.

settings

 

 

Accessing the ASP.NET Web Configuration Tool in Visual Studio 2013

The ASP.Net Web Configuration Manager is not anymore available in Visual Studio 2013. If you need to run it in your development server or machine, the steps below would be of great help. Before doing these steps, ensure that your sites are running on .NET Framework 4.0 or higher.
1. Open the command prompt. Note: You need to open it not as an administrator.
2. You need to be in the IIS Express folder (E.g. C:\Program Files\IIS Express>) and paste the following prompt without a quote:

 “iisexpress.exe /path:C:\Windows\Microsoft.NET\Framework\v4.0.30319\
ASP.NETWebAdminFiles /vpath:/ASP.NETWebAdminFiles /port:8089 /clr:4.0 /ntlm"

Note: Use other port number if 8089 is already assigned.

iisexpress

3. Finally, paste this URL in your browser witout a quote:

"http://localhost:8089/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=
C:\Users\drmindweb\Documents\Visual%20Studio%202013\Projects
\QualityModule\&applicationUrl=/"