Use Master
RESTORE DATABASE DinnerNow FROM
DISK = 'C:\DinnerNow.bak' WITH MOVE
'DinnerNownew' TO
'F:\Program Files\Microsoft SQL
Server\MSSQL.4\MSSQL\Data\DinnerNownew.mdf', MOVE 'DinnerNownew_log' TO
'F:\Program Files\Microsoft SQL
Server\MSSQL.4\MSSQL\Data\DinnerNownew.ldf'
GO
Wednesday, July 25, 2007
How to restore a sql server database backup?
I had backup a database of my SQL Server 2005, however it can't be restore due to the drive location issue, therefore here is the method to overcome this problem:
How to enumerate Generic Dictionary .NET list
At first i found that enumerating a .net Dictionary class seem to be difficult but later i found that there is a way of doing this for example:
//instantiate a dictionary list
Dictionary_PointDic = new
Dictionary();
public Dictionary
PointDic
{
get { return _PointDic; }
set { _PointDic = value; }
}
//add value to named key
public void AddPoints(int point, string
ruleName)
{
int temp = 0;
if (!_PointDic.TryGetValue(ruleName, out
temp))
{
_PointDic.Add(ruleName,
point);
}
else
{
_PointDic.Remove(ruleName);
_PointDic.Add(ruleName,
point);
}
}
//sum up the values in the dictionary list
public int
CalculatePoints()
{
int totalpoints = 0;
foreach
(KeyValuePairs in _PointDic)
{
totalpoints +=
(int)s.Value;
}
return totalpoints;
}
Monday, July 16, 2007
ConfigurationManager .Net
How you read your custom setting in your application configuration file.
//Read settings
public static string ReadConfig(string key)
{
return ConfigurationManager.AppSettings.GetValues(key)[0];
}
//Update Settings & get immediate changes
public static void SetConfig(string key, string value)
{
Configuration con = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
con.AppSettings.Settings[key].Value = value;
con.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection("appSettings");
}
//Read settings
public static string ReadConfig(string key)
{
return ConfigurationManager.AppSettings.GetValues(key)[0];
}
//Update Settings & get immediate changes
public static void SetConfig(string key, string value)
{
Configuration con = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
con.AppSettings.Settings[key].Value = value;
con.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection("appSettings");
}
Subscribe to:
Posts (Atom)