It happens many times that you don’t have access to an ASP.NET server, except for FTP, and you’re interested in finding out the version of .NET Framework or ASP.NET that runs on that server.To find out what version of ASP.NET you have installed and running on a server, using ASP.NET itself, you can use the System.Environment.Version – […]
How to use if/else statements in SQL
The SQL query language supports if/else statements just like most programming languages, and in a similar fashion. Example: The main difference is that instead of using the curly brackets – { and } – BEGIN and END satatements are being used. Following the same flow, an if/else if/else statement looks like this:
What is the difference between #include and #include “”?
In C++ it’s common to see two methods of including a header file: The difference between the two varies on the compiler you are using, however the rule of thumb is that the first version, between the “<” and “>”, will have the compiler search for filename in a series of predefined paths. It is the standard […]
How to fix Cannot modify header information
Cannot modify header information – headers already sent by (output started at …) is a very popular error returned by PHP. You would receive this error if you are trying to set the header of a page after the header has already been sent to the client. There are two main ways of getting around […]
How to select the last inserted record from the identity column
In Microsoft SQL Server, the identity column provides you with an unique id for each record, which is auto-incremented.To get the last added record from the database you will often want to select the latest added ID. Many have the false impression that they can select the biggest ID (number), and that will be the […]
How do I get the list of all session variables?
Cause for ‘Failed to retrieve data for this request’ error in SQL Server 2005
When browsing the database list inside Microsoft SQL Server Management Studio, you may get the error below: Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum) Invalid column name ‘mirroring_role’.Invalid column name ‘mirroring_state’.Invalid column name ‘mirroring_state’. (.Net SqlClient Data Provider) One of the reasons for this error is that you are trying to connect to a […]
Finding the username of the current Windows user with VB.NET
This single line of VB.NET code below will put the name of the current Windows user into the currentUserName variable:
Which is the fastest way of checking if a string is empty?
There are many ways of checking if a string is empty, in C#: string myString = “”;if(myString == “”){ // String is empty} string myString = “”;if(myString.Length == 0){ // String is empty} string myString = “”;if(myString == String.Empty){ // String is empty} Performing benchmarks on these three methods resulted that the second method (myString.Length == 0) is almost three times faster […]
DataBinding: ‘System.Data.Common.DbDataRecord’ does not contain a property with the name x
This is a common error that occurs when you are trying to display a record in ASP.NET from a DataSource such as a SQL database, and a field you requested within the code cannot be found within the result returned by the DataSource. For example if you use a SQL command to retrieve fields, and […]