Category: Software Development
-
MSSQL int to nvarchar
If you need to convert/cast a database integer field to an nvarchar on a Microsoft SQL Server, you should use the convert function. In this example we cast the number 4343 to an nvarchar: Example to convert an int field (field_int) to a nvarchar field: Result from the query:
-
MSSQL datediff in seconds
The following command on a Microsoft SQL Server calculates the difference in seconds between two datetimes: Example query: Result: If you need the result as a text and also want to add 3 digits after the seconds you can use the following example: Result:
-
HTTP header CSV type
The right HTTP header content-type for CSV files is the following: The complete HTTP header: In PHP you should use for an CSV file download the following lines at the start of the file: In C#/ASP .Net you use the following code in the code behind file:
-
Oracle top 1 record
To select the top 1 records from an oracle database, you filter with the where statement on rownum = 1: If you want to select top 10 records from the table you use the following statement:
-
Javascript string in (includes)
Here a quick example how in javascript the includes function on an string works. In other programming language its also known as “in” or “contains” function. Output:
-
C# useful DateTime extensions
Here are some useful C# DateTime extensions, i hope you enjoy it: You can call it from any class like this little example, don’t forget to add the using in the top of you class. Elapsed The function Elapsed returns the time elapsed between now and the DateTime object. If you need a simple stopwatch,…
-
C# Sha512 hash example
Here a quick example how to create a Sha512 hash in C#. We are using the functions from System.Security.Cryptography, so don’t forget to add the using at top of you file.
-
C# Base64 decode and encode
Here is an quick example how to encode/decode a string to base64. This example works already on .net core 2.0 or above.
-
Example SHA256 hash in C#
Here is short code snippet to create a SHA256 hash in C#. The only difficult is to convert from string to byte array and back again. So i have to method, one accept the byte array direct and returns a byte array, the second method handles the convert from string to byte array and back again.…
-
How to create a SHA1 hash in C#
Here is short code snippet to create a SHA1 hash in C#. The only difficult is to convert from string to byte array and back again. So i have to method, one accept the byte array direct and returns a byte array, the second method handles the convert from string to byte array and back again.…
-
How to create a md5 hash in C#
Here a quick example how to create from an string an md5 hash in c# and output it as string. The only difficult is to convert from string to byte array and back again. So i have to method, one accept the byte array direct and returns a byte array, the second method handles the…
-
An alternative for github
If you are looking for a good alternative for github, you should give gitea a try. If you need private repositories or your company have many repositories, you need an payed account at github.com.
-
PHP PDO jQuery AJAX Example
I have found a very nice tutorial, how to use PHP, PDO, jQuery and the ajax technology to create, edit and delete records on a database table. I have copied the script and had make an online demo page from this project. Its like my own German article how to use PHP and Ajax to…
-
.Net Core PDF Library from HTML (DinkToPdf)
If you need an PDF library, wich converts an HTML document to a PDF you need a library. There are a lot of libraries on the market, but only a few wich are free and open source. In my projects i used the DinkToPdf library, wich is a wrapper for the webkit engine (the chrome…