Get latest date record - SQL query

| 2017/10/05 03:02
To return the latest record (one record only) from data base table where one of the fields is in Date/Time format:
SELECT TOP 1 * FROM table_name ORDER BY date_time_column_name DESC
Notes:
TAGS:

C# - Get database connection string from Web.config file

| 2017/10/05 02:45

To get the database connection string from IIS Web.config file using C# code, include System.Configuration directive and then create a string variable to assign the connection string like this:
using System.Configuration;
string connStr = ConfigurationManager.
                  ConnectionStrings["connectionString_Name"].ConnectionString;
If “ConfigurationManager” is not recognized you will need to add reference to: "System.Configuration".See: C# - How to add reference to project

TAGS: |

C# Textbox - enter only positive numbers on KeyPress event in Windows form application

| 2017/10/05 02:27

To prevent users from entering incorrect data in Windows form application, set restriction to allow only specific characters to be entered in the text box.This example uses KeyPress event to monitor the users input and to apply the restriction required.To avoid code duplication in Windows multiform applications for example, a separate class file is created “CommonFunctions.cs”.
The function to allow only numbers in textbox control is named InputNumbers.
For each Windows form, create a single KeyPress event and call the InputNumbers function inside it.

c# passing data between forms

| 2017/10/05 02:07
C# project with two forms
public partial class Form1 : Form // this is the main form

public partial class Form2 : Form // this is the second form
To pass variables (values, data) from Form1 to Form2
Case: public variables in Form2
public string input_variable; // put this in Form2 as global variable

public string output_variable; // put this in Form2 as global variable

in Form1 inside the function that run (call) Form2
TAGS:

C# How to draw shapes – Circle, Rectangle, Arc, Pie, Polygon, Bezier, Text

| 2017/10/05 01:56
In order to draw shapes in C# a start point and end point coordinates, and a Pen control must be defined first.
Coordinates in C#The value of x is the location of the point along the x-axis, the 0 is at the extreme left. The value of y is the location of the point along the y-axis, the 0 is at the extreme top.
TAGS: |