Friday, November 18, 2011

Maintain multiple Facebook accounts

If you are having more than one Facebook accounts(or even one) and you can add this extension named "Quick Login for Facebook Accounts" to your Chrome browser. The extension is from the guys who have created the  extension "Quick Login for Gmail" (my previous post). This is also pretty simple and cool.

More information can be found here;
Quick Login for Facebook Accounts

One click does the magic. :)

Chrome Extension to maintain multiple gmail accounts

It is little harder to keep remember passwords of our Gmail accounts all the time. Recently, I have found the following chrome browser extension "Quick Login for Google Accounts" which solves the above problem. No more worries about the password maintenance. It is also secure.

More details about the Quick Login chrome extension;
Quick Login for Google Accounts

Really good and simple extension. Thanks to the guys who created this.

Monday, January 25, 2010

Simple LINQ - SQL Connecting Program in C#

LINQ - Language Integrated Query.It provides the Querying ability to the database and also doing the DML operations such as insert, update and delete.for more about LINQ, have a look at http://msdn.microsoft.com/en-us/library/bb308959.aspx

There are infinite pages are available to describe the Linq, its functionality, and design. But for a beginner, let us go with creating a simple application using Linq and playing with database. Before writing the program, we need to know the following basic things.
1. DataContext

This is a Layer or cache kind of stuff which interacts between the database and application. The application uses the datacontext to manipulate data with the database.
2. dbml - Database Markup Language
Linq to SQL class is known as dbml. The dbml maintains the tables and linkings.

Now we start with creating simple program. The aim of the program is to display the Northwind customers data whose names are starting with "a" in a datagrid.
Step 1: Create new C# windows project in VS2008.
Step 2: Import SqlClient/Oledb classes for database usage.
Step 3: Create dbml file. Right click Project and add New Item. Choose the "LINQ to SQL Classes" from the templates section. Name it as you like, here let us name it as "SampleNwnd". The extension would be ".dbml".
The dbml file will be opened with empty designer window saying that "Create data classes by dragging items from "Server Explorer" or "Toolbox" onto this design surface.
Step 4: Click the "Server Explorer" link and create a data connection. Right Click "Data connection" and click "Add Connection". This will open up the "Add Connection" window which contains the SQL Server credentials, database and authentication. Choose the appropriate settings and click "Ok" to complete the connection.

Once the connection has been added, the database tables, schema, procedures, views everthing will be shown.
Just drag and drop the Tables, Views to the dbml design window. To create the linking/association between the selected tables, Right click dbml screen ==> Add ==> Association. The Association editor will be shown. From there we can bind the master and child table relationship.

The next thing is coding part. We need to use the dbml in the coding. We may play with database activities such as view, insert, update and delete. Here let us display the list of customers in Northwind database whose names are starting in "a".
Here is the simple code;

private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection("connection string");
conn.Open();
SampleNwndDataContext nwnd = new SampleNwndDataContext(conn);
var customers = from cust in nwnd.Customers
where cust.First_Name.StartsWith("a")
select cust;
dataGridView1.DataSource = customers;
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
The above code will display the data in a gridview. Here, "SampleNwndDataContext" is the data context class which we have added in the project. The tables which are added in the dbml file, those will be accessible inside the program. There are enormous options in LINQ to explore. But I believe this will be a starting point on that.
For more sample programs on LINQ, have a look at http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

Saturday, December 26, 2009

Character casing in Asp.net

We might used the "Charactercasing" property of Textbox in C# windows applications. This is used to get the input values as upper or lower case without doing the separate coding. But in web applications,this property is not available directly. But we need to achieve this functionality using CSS.

In CSS, we need to use the "text-transform" property to make the input text as upper, lower or initcaps.

Here is the CSS sample:

.makeuppercase
{
text-transform:uppercase;
}
.makelowercase
{
text-transform:lowercase;
}
.makeinitcaps
{
text-transform:capitalize;
}

Need to assign the style name to TextBox "CssClass" property as;

TextBox1.CssClass = "makeuppercase"

The above code will make the input values to upper case while entering the values.