Thursday, June 14, 2007

Create a distributable workflow enabled smart client

We want to develop a windows application with workflow enabled. The easiest and fastest way is to use Microsoft Workflow Foundation which give you a complete API for designing any workflow application that you can think of.

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

SqlCeCommand command = new SqlCeCommand(queryString, connection);
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






Saturday, May 26, 2007

You are trying to access an older version of a SQL Server Compact Edition database. If this is a SQL Server CE 1.0 or 2.0 database, run upgrade.exe.

This happens when your .sdf database version changed and perhaps corrupted. It might due to merge replication of using SQL Server 2005. Therefore the only solution is to repair it.

To repair it you must use the
System.Data.SqlServerCe.SqlCeEngine class, version 9.0.242.0 or 3.5.0.0

Here is the example of the implementation.


File.Copy(@"F:\northwind.sdf",@"F:\northwind.sdf.temp");
File.Delete(@"F:\northwind.sdf");
SqlCeEngine
engine = new SqlCeEngine(@"Data Source
=F:northwind.sdf.temp");
engine.Compact(@"Data
Source=F:\northwind.sdf");
File.Delete(@"F:\northwind.sdf.temp");



A repaired northwind.sdf is produced and now you should not be getting this error again. Any other alternative? Please let me know. :)

Friday, May 25, 2007

Before trying to solve, think first

most of us solve problem as straight away try to do it without thinking or planning when given a problem. This often lead to slow productivity because the method used is not effective enough to solve the a given problem. Perhaps there is a better way solving the problem, you might not know it. Therefore just keep these checklists in mind before starting any problem solving:

Do your research and gather as much information as you can.
Any question, don't wait... ask Google.
Give yourself various alternative solutions.
Be creative and don't afraid to break the rules.


If you could follow all these mention above, you could be a better problem solver.

Wednesday, May 23, 2007

software user interface design.

User interface is very important to improve the usability of the software. Software application failed to meet user expectations and requirements are often due to the lack of proper UI design. Simple UI often impress user whereas complex UI often frighten user away. When design UI, the first thing have to come to every developer mind; always design in user perspective.

A great UI must always have these criteria:

simple and does the job right.
good navigation and proper UI arrangement
easy accessible functions and customized menu for the user
fast and responsive UI

please keep in mind that UI design is the first user impression of the software.