From sample code, you will see nice thing that can be useful in programming
--------------------------------------------------------------------------
System.Text.StringBuilder sb = new System.Text.StringBuilder("Rat: the ideal pet");
sb.Append(" is caught");
sb[0] = 'C';
System.Console.WriteLine(sb.ToString());
System.Console.ReadLine();
-----------------------------------
Output : Cat: the ideal pet is caught
Thursday, July 21, 2011
Thursday, July 14, 2011
Padding character before a string in sql query
select right(replicate(@padchar, @len) + @str, @len)
e.g. select right(replicate('0', 10) + 'hell boy', 10)
e.g. select right(replicate('0', 10) + 'hell boy', 10)
Wednesday, July 13, 2011
Expression evaluation in C#
Try with this code block which is faster than using codeDom
----------------------------------------
static double Evaluate(string expression)
{
var loDataTable = new DataTable();
var loDataColumn = new DataColumn("Eval", typeof(double), expression);
loDataTable.Columns.Add(loDataColumn);
loDataTable.Rows.Add(0);
return (double)(loDataTable.Rows[0]["Eval"]);
}
----------------------------------------
static double Evaluate(string expression)
{
var loDataTable = new DataTable();
var loDataColumn = new DataColumn("Eval", typeof(double), expression);
loDataTable.Columns.Add(loDataColumn);
loDataTable.Rows.Add(0);
return (double)(loDataTable.Rows[0]["Eval"]);
}
Friday, June 24, 2011
Database Restore, Error 3154
Error detalils:
Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing 'dbName' database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
----------------------------------------------------------------
Solution:
RESTORE DATABASE dbName--AdventureWorks
FROM DISK = targeted location -- e.g. N'K:\june_24.bak'
WITH REPLACE
Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing 'dbName' database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
----------------------------------------------------------------
Solution:
RESTORE DATABASE dbName--AdventureWorks
FROM DISK = targeted location -- e.g. N'K:\june_24.bak'
WITH REPLACE
Thursday, April 29, 2010
Thursday, April 22, 2010
Subscribe to:
Posts (Atom)