Posts

C# - DateTime To String

String _display = DateTime.Now.ToString("dd/MM/yyyy"); _display result is: 27/12/2011 You can display by .NET Datetime format characters as the following: d - Numeric day of the month without a leading zero. dd - Numeric day of the month with a leading zero. ddd - Abbreviated name of the day of the week. dddd - Full name of the day of the week. f,ff,fff,ffff,fffff,ffffff - Fraction of a second. The more Fs the higher the precision. h - 12 Hour clock, no leading zero. hh - 12 Hour clock with leading zero. H - 24 Hour clock, no leading zero. HH - 24 Hour clock with leading zero. m - Minutes with no leading zero. mm - Minutes with leading zero. M - Numeric month with no leading zero ex.2. MM - Numeric month with a leading zero ex.02. MMM - Abbreviated name of month ex.Dec MMMM - Full month name ex.December. s - Seconds with no leading zero. ss - Seconds with leading zero. t - AM/PM but only the first letter. tt - AM/PM ( a.m. / p.m...

MSSQL - Set permission to update database MSSQL2008

In MSSQL2008 Server, when you change/edit table schema, sometimes you can not save change. The error you found is " Saving change is not permitted . The changes you have made require the following tables to be dropped and re-created....." You can fixed this problem with this solution. Solution: - In SQL Server Management Studio > Go to Tools Menu > Options > Designers - Find the option "Prevent saving changes that require a table re-creation" and unchecked it. Now, you can save changed your new schema.

C# - Convert Image URL To BASE64

public String ConvertImageURLToBase64(String url) {      StringBuilder _sb = new StringBuilder();      Byte[] _byte = this.GetImage(url);      _sb.Append(Convert.ToBase64String(_byte, 0, _byte.Length));      return _sb.ToString(); } private byte[] GetImage(string url) {      Stream stream = null;      byte[] buf;      try      {           WebProxy myProxy = new WebProxy();           HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);           HttpWebResponse response = (HttpWebResponse)req.GetResponse();           stream = response.GetResponseStream();  ...

MSSQL - how to change "SA" password

1. Open the "SQL Server Enterprise Manager". This is usually under "Start"-->"Programs"-->"Microsoft SQL Server". 2. Navigate to the "Logins" object under the "Security" folder on the SQL Server you wish to administer. Then, right click on the 'sa' account and select "Properties". 3. Now, enter a new password in the "Password" field under the "Authentication" options. website reference: http://www.eukhost.com/forums/f31/how-change-mssql-sa-password-511

MSSQL - select a random row

Microsoft SQL Server provide function "NEWID()" to random record from database. Let's see example. SELECT TOP 1 column FROM table ORDER BY NEWID() Example: SELECT TOP 1 code_item FROM game_item WHERE available=1 ORDER BY NEWID()

MSSQL - how to select all table name

In Oracle, you can use statement "select * from tab" for get all table name in your database. But for MSSQL you have to use "select * from sys.Tables" instead of "tab". Example. USE nothwinds SELECT * FROM SYS.TABLES

HTML - Image Lightbox

Image
If you need to show the full size overlay image on the current page. "Lokesh Dhakar"'s coding is a good example. His code is on javascript and stylesheet. Please visit Lokesh's site to download & see the example. URL Reference: http://www.huddletogether.com/projects/lightbox2/ Example: if you click on thumbnail image. You'll get the full image like this.