Category: C#

4

Implementing MVP Pattern using UserControls with WCF Database Operations in Entity Framework and LINQ – PART I

First we create a database – ‘CustomersDB’ – with a table in it – ‘Customers’. This table Customers holds the basic data related to each and every customer. Then we create the entity model for this CustomersDB using ADO.Net Entity Framework. After that we create a WCF service with minimal end point configuration to access ServiceContracts which do basic database operations. Instead of coding the data access methods (of the class implementing ServiceContract) in traditional ADO.Net queries, we tend to use LINQ for the same. Once the service is ready, we host it using a Console App. With this we complete the backend of the article. Now we implement the MVP pattern for better separation of UI from its code with the help of presenter class. So we create an interface for both model and view and then implement them in their respective class. Finally we create a UI with some UserControls in it for adding/editing/deleting customers from the front end.

31

Retrieve files from a table in Database using Generic Handler

In the first part of this tutorial (PART I – Click Here), we uploaded files to the database in binary format using a FileUpload control. The plot behind saving files is to take the file from the FileUpload control, convert the same to the binary format, then save it to the DB. To make our accomplishment more flexible and maintainable, we use stored procedures along with custom classes for database transactions.

In this part of the tutorial, we retrieve the files (which are stored in a table of a database). For this purpose we first create a custom class which will hold the code for database transactions, then we create a generic handler which will process all the incoming requests for the downloading of files. Finally we create a web page which uses the before mentioned class and handler along with a repeater control to make the file available to the client.

14

Save files to a table in Database using FileUpload control

In this tutorial, we first save files to the database in binary format, then in the second part of the tutorial we see how to provide a download option to the files residing in database. For uploading the files to DB, we use a FileUpload control and to provide download facility we make use of a Generic handler. The plot behind saving files is to take the file from the FileUpload control, convert the same to the binary format, then save it to the DB. To make our accomplishment more flexible and maintainable, we use stored procedures along with custom classes for database transactions. And the plot behind retrieving files is to use a handler which process the incoming request which are made to the files in database.

11

Simple Html Editor based Comments Section with Captcha feature along with Database Interactivity

In this tutorial, we see how to develop a simple comments section. This comments section is going to be a similar one to what we usually see in our day to day experience. Here we use TinyMCE editor to enable Html Comments. And also catpcha is enabled (with the help of reCaptcha of Google). The basic outline would be – Users provide their general details like name and email, and also they can provide Html Comment (using TinyMCE), and finally they should enter the text showed in the captcha for validating robots. Then we take the Html string, encode it using HtmlEncode(), store it in database. Finally we retrieve the encoded string from the database, we then decode it and display it in the page as Comment.

160

Sending Automated Emails asynchronously using a C# Windows Service in conjunction with Database Email records PART – II

In this part of the tutorial, we first create a Windows Service Project, then implement a Service called – ‘BirthdayEmailService’. Then we add a reference to our previously created Class Library – ‘EmailComponent’. We code BirthdayEmailService using Timer to perform the email sending task for every hour. Then we incorporate the Installer classes for the purpose of installation. Finally a Setup and Deployment Project is created for the Service. Finally the complete Solution is build and the exe file is generated which is ready enough to get installed.

52

Sending Automated Emails asynchronously using a C# Windows Service in conjunction with Database Email records – Part I

In this tutorial, we learn how to send automated birthday wish emails to the customers of our product. We first design our database with basic details of every customer, and of course with a Email address field. Then we create a class library to hold the classes of database interactivity and to send email asynchronously. We use ADO.Net (for this tutorial I am skipping Entity Framework implementation, which usually I prefer to interact with Database. For generating EF modules of database, kindly watch this tutorial – Click Here) with a stored procedure for database interaction (primarily to fetch email ids of customers to whom we got to send birthday wishes). Then finally we use a Windows Service (which obviously run background in the server)through which the previously created class library is accessed and async emails are send.

11

Create a Simple WCF Service Client against Pubs Database using EF, LINQ – Part II

1) In this tutorial (which is PART – II), we create a small website in ASP.Net 4.0 and we shall use a WebForm (named: PubsServiceTestPage.aspx) as a client to our service (which we created in former tutorial).
2) We Use the inline model of Webform (not the codebehind model).
3) We perform the actions using our client like, Getting all the Authors and display them in the Dropdownlist for selections, Selecting a Author and display his corresponding books using a Repeater, Modify and save the book details back to database etc.
4) To test the Client, we need the service to be running in the server, that can be simply manipulated by starting another instance of VS 2010 and running (Ctrl + F5) the PubsService.svc.cs.

28

Create a Simple WCF service against Pubs Database using EF, LINQ – Part I

1) In this tutorial we create a simple WCF service which is used to retrieve and save data from Pubs Database (Microsoft sample database).
2) The service also demos on how to use EF 4.0 and LINQ against database coding, with no requirement of writing SQL queries.
3) The continuation of this tutorial shows on how to create a client (say a WebForm in a website) to utilize this service.

0

JumpStart # 2 – OUT Parameter in C#

Before looking at the code, Read about – What is JumpStart? <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> /* OUT PARAMETER – * 1) OUT parameter is...

0

JumpStart # 1 – Using Optional And Named Parameters in C#

Before looking at the code, Read about – What is JumpStart? <%@ Page Language="C#" %> <%@ Import Namespace="System.Runtime.InteropServices" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs...

1

Enumerating, Managing and Monitoring File system using C#

Applications often need to read and write data to the disk, sometimes for the sake of user and most of the times for its internal use. To do this task we need to review the present file system of the disk and then manage the resources according to our requirements. In some applications, it is required to monitor any changes made to the file system and notify them accordingly.

Although there are number of articles written on the web about this topic, still I want to go with this topic in detailed for one more time. The main aim of this article is to understand the file system and manage it through some inbuilt C# classes. The article is written keeping beginners in mind.Read More…

101

How to send an Email using C# – complete features

This article provides detailed information on how to send Email using C# in a step by step procedure. Although there are many articles on the web providing the same info, many of them left out some interesting concepts untouched. Concepts like Alternate Views, Linked Resources add an additional fragrance to the world of Email in C#.

Out of my experience in the fascinating world of ASP.NET and C#, it’s been observed that many of the new programmers often run into lot of doubtful scenarios while performing an Email assignment. The thought of helping new comers is my prior motivation which made me to write this article.Read More…