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?
How to enumerate Generic Dictionary .NET list
//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
//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");
}
Thursday, June 14, 2007
Create a distributable workflow enabled smart client
We wanted to develop a windows application which has to be distributed to multiple computers and having multiple users. Here we have one challenge, we need to host the Workflow. The most simple implementation is to host workflow in a dedicated server where many clients can access to it. Next we have to expose the workflow as webservice, this is important because workflow as webservice can give you the maximum flexibility in connectivity and interoperability. For example, connect a mobile device that runs java application. Sound interesting?
I will post the tutorial on building your first smart client workflow enabled application here for your reference.
Wednesday, June 6, 2007
Short hand using if else for ADO.NET
command.Connection.Open();
ccommand.Parameters.Add("@AddressID", (object)AddressID?? DBNull.Value );
SQL Compact return new insertion identity
Try this code it will help.
public Int64 AddCustomer(string LastName, string FirstName, int?
AddressID, string MembershipUsername, string PhoneNumber, string
MobilePhoneNumber)
{
SQLCeHelper sqlce = new
SQLCeHelper(Properties.Settings.Default.CarServ3DB4ConnectionString);
string
queryString =
"INSERT INTO Customer" +
"(LastName, FirstName, AddressID,
MembershipUsername, PhoneNumber, MobilePhoneNumber)" +
"VALUES
(@LastName,@FirstName,@AddressID,@MembershipUsername,@PhoneNumber,@MobilePhoneNumber)";
Int64
newIdentity = 0;
using (SqlCeConnection connection = new
SqlCeConnection(
Properties.Settings.Default.CarServ3DB4ConnectionString))
{
SqlCeCommand
command = new SqlCeCommand(queryString,
connection);
command.Connection.Open();
command.Parameters.Add("@LastName",
LastName);
command.Parameters.Add("@FirstName",
FirstName);
command.Parameters.Add("@AddressID", (object)AddressID??
DBNull.Value );
command.Parameters.Add("@MembershipUsername",
MembershipUsername);
command.Parameters.Add("@PhoneNumber",
PhoneNumber);
command.Parameters.Add("@MobilePhoneNumber",
MobilePhoneNumber);
command.ExecuteNonQuery();
SqlCeCommand command1 = new
SqlCeCommand("select @@identity ", connection);
newIdentity =
Convert.ToInt32(command1.ExecuteScalar());
}
return
newIdentity;
}
Thursday, May 31, 2007
FileNotFoundException was unhandled
Could not load file or assembly 'System.Data.SqlServerCe, Version=9.0.242.0,
Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified.
You might encountered this error when the System.Data.SqlServerCe version has redirected to another newer version due Visual Studio 2005 generated code on your application config file.
To solve this problem, you have to delete something like below in you app.config file.
xmlns="urn:schemas-microsoft-com:asm.v1"> name="System.Data.SqlServerCe" publicKeyToken="89845DCD8080CC91"
culture="neutral"/>newVersion="9.0.242.0"/>
hope this helps