PayPal Direct Payment for C# developers

PayPal integration allows ASP.NET developers to create a Payment Data Transfer (PDT) via PayPal API express checkout to allow direct payments. PayPal Sandbox is a test account which will allow developers to test such API in order to avoid actual payments and transaction fees or interests. Continue reading

unrecognized escape sequence

While using the Regex class to validate email using C# code, an error stating “unrecognized escape sequence” was being returned when presenting the following code:

public bool ValidateEmail(string Email)
{
bool valid = Regex.Match(Email, “\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b”).Success;

return valid;
}

The solution was simple … adding an @ in front of the regex, enables the escape after each “\” in the sequence… therefore new code is:

public bool ValidateEmail(string Email)
{
bool valid = Regex.Match(Email, @”\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b”).Success;

return valid;
}

This may be valid for more other scenarios 😉

ADO.NET Execute Commands .. When to use what ??

SqlDataAdapters for SqlCommand

A database on a server (example: MySql, msSql, etc) is all accessed by ADO.NET using SqlConnection objects. There are typically four tasks we can perform using SQL which are, selecting queries from database, insert, update and delete. Each having different ADO.NET SqlCommand objects to query the different statements. SqlCommands are mainly divided in two categories, SqlDataAdaptors (disconnected) and SqlDataReaders (Connected). The mostly used SqlDataAdaptors are the: Fill() command, ExecuteScalar(), and ExecuteNonQuery().  For each, an example will be displayed below along with some explanation.

Continue reading

Linq to SQL using Stored Procedures in nThier Design

After doing a lot of research, I realised that when using Linq to Sql to communicate with the database, it is quite impossible or too complicated to use datatables or datarows. In this example I will demonstrate an easy and quick way to retrieve a whole table from a database using stored procedures assuming we are using a three thier design.

Continue reading

LinQ to SQL simple Insert Update and Delete

Since I was given a task to implement new technologies, I came about selecting LinQ. It was quite hard to find a simple place or tutorial where I could find how to do simple queries without complexities. Therefore I decided to post a blog to describe as simple as can be the process of inserting updating and deleting from LinQ to SQL.

Continue reading