Posts

Showing posts from 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.

XML Documentation comments

Image
When we are doing the coding, we need to use our own functions/methods to do a certain task. But while writing the function we may missed out the function details like why the function has been written . So whenever writing a function, if we use the documentation comments standard, it will help in the future whoever uses the function. Here is syntax; /// /// documentation block /// Here is the simple function defined in C# IDE; documentation comments added here; Intellisense is displaying the documentation comments.

Storing Images in MySQL database

Image
We may need to store the images in the database. It is easy and pretty simple. The basic idea is; 1) The images are stored in database as bytes. In MySQL database we need to create a field/column of type " Blob ". 2) Need to use FileStream and BinaryReader objects to convert images into bytes. Here is the C# code, to do the task Table schema: C# code: MySqlConnection mcon = null; MySqlCommand cmd = null; FileStream fsObj = null; BinaryReader binRdr = null; try { //converting image to bytes fsObj = File.OpenRead(pictureBox1.ImageLocation); byte[] imgContent = new byte[fsObj.Length]; binRdr = new BinaryReader(fsObj); imgContent = binRdr.ReadBytes((int)fsObj.Length); mcon = new MySqlConnection("server=localhost;user=root;pwd=root;database=test;"); mcon.Open(); //inserting into MySQL db cmd = new MySqlCommand("insert into users (userid,username,userphoto) values (@userid, @username, @userphoto)", mcon); cmd.Parameters.Add(new MySqlPara

Oledb and SQL Clients

While dealing with database stuff in .Net, we might worked with Oledb and SQL Clients. Here are, some of the methods which help us to get the database tables, views, primary keys...etc OLEDB Client/ SQL Client Namespace System.Data.OleDb/ System.Data.SqlClient ConnectionString Provider=SQLOLEDB.1;Persist Security Info=False;User ID={user};Password={password};Initial Catalog={Database};Data Source={host name/IP}; Server={host name/IP}; Database={dbname}; User ID={user}; Password={sqlServerPassword}; For various connection strings, have a look at connectionstrings Getting Table list from database DataTable dtObj = {connection}.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object() {null, null, null, "Table"}); DataTable dtObj = {connection}.GetSchema("Tables"); Getting Views List DataTable dtObj = {connection}.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object() {null, null, null, "View"}); DataTable dtObj = {connection}.GetSchema(&q

DataTable ExtendedProperties

While playing in data tables in .net, it may require to have some temporary values such as records counts, primary key field name, …etc. In those situations, instead of declaring new variables in the program, it is ideal way to use “ExtendedProperties” option in datatable. The property is holding the collection (hashtable) values. Here is the syntax; DataTable.ExtendedProperties.Add (object key, object value); Examples; DataTable dtObj = new DataTable("employees"); dtObj.ExtendedProperties.Add("totalCount", 500); dtObj.ExtendedProperties.Add("primaryKey", "employee_id"); dtObj.ExtendedProperties.Add("createdDate", DateTime.Now); For retrieving assigned properties, int iCount = Convert.ToInt32(dtObj.ExtendedProperties["totalCount"].ToString()); So simple and effective property.

SQL Server Editions

Recently I have read an article about Microsoft SQL Server editions. It made surprise for me that Microsoft has been released 10 different versions of SQL Server. Here I am giving some of the key points on the editions. SQL Server Compact Edition (SQL CE) The compact edition is an embedded database engine. It is limited to 4GB maximum database size and cannot be run as a Windows service, Compact Edition must be hosted by the application using it. SQL Server Developer Edition SQL Server Developer Edition includes the same features as SQL Server Enterprise Edition, but is limited by the license to be only used as a development and test system, and not as production server. SQL Server 2005 Embedded Edition (SSEE) SQL Server 2005 Embedded Edition is a specially configured named instance of the SQL Server Express database engine which can be accessed only by certain Windows Services. SQL Server Enterprise Edition SQL Server Enterprise Edition is the full-featured edition of

ASP.NET Video Tutorials

ASP.NET Video Tutorials are available here http://www.asp.net/learn/ Excellent videos. We can download too.

Chennai Bus Routes

Guys, Here is a nice website which is useful for finding Bus route numbers in Chennai. http://rab.in/bus/chennai/

MCTS free Tests

Hi, Those who are interested in doing Microsoft certifications, visit this site to test yourself. You may find how strong you are in .NET technologies. http://www.accelerated-ideas.com/aiMExamsChoose.aspx Best of luck. :) -Sam

Currency Calculator

Simple and Easy online currency calculator. http://www.x-rates.com/calculator.html# I liked :)