var statu = from x in dc.Attendance group x by 1 into g select new { ID = g.Key, Presents = g.Where(t => t.AttendanceStatus == "Present").Count(), Absents = g.Where(t => t.AttendanceStatus == "Absent").Count(), Leaves = g.Where(t => t.AttendanceStatus == "Leave").Count(), };
world wide web development problems asp net php html xhtml css javascript jquery w3dproblems
Tuesday, April 22, 2014
LINQ Case statement within Count asp net c#
Monday, April 21, 2014
unique key based on 2 or more columns in SQl Server 2005 or later
CREATE UNIQUE NONCLUSTERED INDEX IX ON Tbl ( Col1 , Col2 , Col3 ) WITH( IGNORE_DUP_KEY = OFF)
Breaking out of a nested loop c# aspnet
for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { if (exit_condition) { // cause the outer loop to break: i = INT_MAX; // break the inner loop break; } } }
IIS - this configuration section cannot be used at this path (configuration locking?)
For Windows 7
For Windows Server 2012
- Click "Start button"
- in the search box, enter "Turn windows features on or off"
- in the features window, Click: "Internet Information Services"
- Click: "World Wide Web Services"
- Click: "Application Development Features"
- Check (enable) the features. I checked all but CGI.
For Windows Server 2012
- Configure Web Server(IIS) inside roles and features
- Add all features including dot net framework 4
Thursday, April 17, 2014
How to get name of all tables in ms sql database aspnet c#
public System.Collections.Generic.Dictionary<string, string> GetAllTables(System.Data.SqlClient.SqlConnection _connection) { if (_connection.State == System.Data.ConnectionState.Closed) _connection.Open(); System.Data.DataTable dt = _connection.GetSchema("Tables"); System.Collections.Generic.Dictionary<string, string> tables = new System.Collections.Generic.Dictionary<string, string>(); foreach (System.Data.DataRow row in dt.Rows) { if (row[1].ToString().Equals("BASE TABLE", StringComparison.OrdinalIgnoreCase)) //ignore views { string tableName = row[2].ToString(); string schema = row[1].ToString(); tables.Add(tableName, schema); } } _connection.Close(); return tables; }
Wednesday, April 16, 2014
Populate a SQL Server column with a sequential number
DECLARE @id INT SET @id = 0 UPDATE Table SET @id = id = @id + 1
Tuesday, April 15, 2014
Specified initialization vector (IV) does not match the block size for this algorithm
The initialization vector size needs to be 16 bytes or in easy words 16 chars
Monday, April 14, 2014
asp net c# crystal report server side printing
Exposing printer settings to the SYSTEM account
When a printer is installed on a computer, its settings are stored in the HKEY_CURRENT_USER registry key. IIS runs under the context of the local SYSTEM account. It has access to the HKEY_USERS registry key, but not to the HKEY_CURRENT_USERS subkey, which is only available to a user logged on to the computer.By default, no printers are defined in the HKEY_USERS key. You can add them by exporting three keys from the HKEY_CURRENT_USERS key and importing them to the HKEY_USERS key
NoteCaution Incorrectly editing the registry might severely damage your system. Make sure you back up valued data before making changes to the registry.
To make printer settings available to the SYSTEM account:
- Check that the current user on the Web server has the required printer(s) installed.
- To launch the Registry Editor, type regedit in the Start>Run dialog box and click OK.
- Select the HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion key and export the registry key from the File or Registry menu.
- Specify a name and location in the Export Registry File dialog box and click Save.
- This file provides a backup if you need to restore the registry.
- In the HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion key, select the Devices subkey and export the registry key.
- Specify the name devices.reg and a temporary location in the Export Registry File dialog box and click Save.
- Repeat steps 5 and 6 for the PrinterPorts and Windows subkeys, naming the files printerports.reg and windows.reg.
- Open devices.reg in Notepad (do not use TextPad or another editor), replace the string HKEY_CURRENT_USER with the string HKEY_USERS\.DEFAULT (note that there is a dot before DEFAULT), and save the file.
- Repeat step 8 for printerports.reg and windows.reg.
- Double-click each of the edited files to import them into the registry.
- Restart IIS so that the configuration changes take effect.
Best way to iterate over a Dictionary in asp net c#?
foreach (KeyValuePair<int, string> entry in dicObj)
{
//body
}
Subscribe to:
Comments (Atom)