Kamis, 12 Januari 2012

Simple DataReader in C#

Today, I want to tell the absolute beginner how to read a value from a SQLDataReader in C#.
If you are an experienced ADO.NET developer then this article will be a complete bore for you. But, believe it or not, there are people who are trying to learn how to work with databases in C#. So maybe I can help out at least one person!
What is an SQL DataReader? DataReaders are a fast way to pull records from a database when all you want to do is simply READ. You may have heard the term "Firehose Cursor" used to describe a DataReader. A firehose is a good comparison because the water (data) only flows one way and it flows fast. DataReaders can not be used to update data, delete data, or anything else other than reading. A good example of when to use a DataReader would be cities in a state. You may want to read out all cities in New York and since they aren't exactly changing every day, you would want to pull them down as fast as possible.

Ok, I promised fast and easy so here goes.
First, you must instantiate (create) a new database connection. Now, I am only working with Microsoft's SQL server today. If you need help converting this article to other database platforms like Oracle or MySQL then please let me know.

Make sure you are also using the needed namespaces before you begin.

using System.Data;
using System.Data.SqlClient;

SqlConnection adoConn = new SqlConnection("Data Source=server;Initial Catalog=database;Persist Security Info=True;User ID=username;Password=password");
adoConn.Open();

Database is now created and opened. The string that we passed is called the "Connection String". All it does is tell the database how and where to open the connection. Substitute "server", "Initial Catalog", and "User ID/Password" with your database information. Remember, this is ONLY an open connection. The database is sitting there waiting on a command. And that is exactly what we setup next. A command. Think of a command as a direct order you give the server (even though it may or may not listen!).

// new command
string sql = "SELECT CustomerName FROM MyTable";
SqlCommand adoCmd = new SqlCommand(sql, adoConn);

The sql string is simply a SQL command we are passing. The adoConn is telling the command which connection to use. Simple, huh?

Ok, now we have an open connection and a command (using the sql string). Our next move is to create the DataReader and display some data.

SqlDataReader adoDR = adoCmd.ExecuteReader();

if (adoDR.HasRows)
{
while (adoDR.Read())
{
Response.Write(adoDR["CustomerName"].ToString());
}
}

The ExecuteReader() method sends the SQL data from the command (our SELECT statement) and if there are records, brings them one at a time down to the DataReader (adoDR).

You'll notice that we first called the .HasRows condition. It's always good to first make sure there is data returned before you do anything with it. The next statement might look a little confusing. This while loop brings each record down one at a time. See, when you call the ExecuteReader and assuming there are rows, you actually start at position "-1". Strange, huh? For example, let's say that SELECT statement returned 50 rows of data. The first record number would be 0, the next would be 1, then so on until record 49. 0-49 records. Everytime you call the .Read() on the DataReader, you advance a record. So, if you started at -1 and advanced a record you would be at the beginning. Record 0. Calling .Read() will continue to return TRUE until you reach the last record. So as you can see, this makes it convenient to cycle through all records. Also I should mention you HAVE to call it at least once to advance to the first record.

The Response.Write command simply sends the data to the web page. This could have been Console.WriteLine, etc. Notice how the "CustomerName" was used. Be careful here because you want to make sure you don't try to call a field in a table that you didn't SELECT.

Ok, the last thing to do is close connections and dispose so that we don't create memory leaks on the server.



adoDR.Close();
adoDR.Dispose();
adoCmd.Dispose();
adoConn.Close();
adoConn.Dispose();

Noticed I reversed the order that I used when creating the objects. DataReaders are opened when you call the ExecuteReader() and when you open something, you should close it. Calling .Dispose() on these objects would also close them but closing them myself has always been a habbit of mine. Command objects aren't opened or closed so no Close() is needed. And finally we close/dispose of the database connection.

There. Was that so hard? We created a database connection, opened it, created a command (using a custom SQL query) and executed the DataReader. Then, we looped through the records. Finally, we closed and disposed of all the objects.

There you have it. Simple. ADO.NET has made it really easy to display data. This is just a tiny scratch on the Titanic. ADO.NET could fill 50,000 pages!

I hope you enjoyed this article. I have to admit, I'm not much of a writer but I remember the first time I pulled data from a database and I wished I had someone telling me in plain English how to get right to the point.
Obviously, we didn't cover other topics like error trapping, DataGrids, DataSets, etc. Those will come in time!

How To Select The Notebook That Meets Your Requirements?

For the past ten years there has been a tremendous growth in the usage of notebook or laptop computers. The impact is that the notebooks are slowly replacing the traditional desktop computers from home as well as from office. There are so many varieties, technologies and brands of notebooks available in the market that it has become very difficult for a regular user to identify the best fit for his or her needs. This article will help you in getting a few tips on how to select the right notebook and make the most out of your investment.

A notebook offers several advantages. The most important being the trouble-free mobility. This is enhanced by the easily available wireless internet connections all over the world. It is very convenient to carry all your work with you anywhere you go. Advancement in technology has brought down the weight and size of the notebooks significantly, making it even more comfortable for a regular user.

What are the things that you should consider before purchasing your notebook? Start with doing an analysis of your needs. Ask questions like: For what purpose will I use this notebook? The answers could include -- for internet browsing, chatting, high-end graphic designing, gaming, business or official work, programming, application development, etc. The type of notebook you choose will depend on what you need it for.

When you do your research, make notes on the prices, technical features, configuration, guarantees, and performance that each notebook has to offer. You would need to decide whether you want a notebook from an Original Equipment Manufacturer (OEM) or from a brand. It is believed that brand notebooks offer better post-sales service, and guarantee, while OEM notebooks are cheaper and offer the same hardware quality as the brand ones.

If you need a notebook that is small and light and should be carried around easily while you are traveling, go for the ultra-portable range models. These notebooks have screens smaller than 12 inches and weigh up to 5 pounds. Some models of such notebooks include Sony Vaio PCG-U3, Fujitsu Lifebook P1510, Toshiba Libretto U100, Panasonic R4, Dell Latitude X1 and many more.

If you are a business professional looking for a thin and light notebook that offers durability, security and all important features necessary for your office, then you can select from a wide range of business notebooks. These include Apple MacBook, Dell XPS M1210, Sony VAIO FJ, and Dell Latitude and etc.

If you are addicted to gaming you would need a notebook that has the capability to present high-end graphics performance. These would include notebooks with the latest processors, increased RAM and hard disk storage space, faster CPUs, top-of-the line graphic display capability, great wireless connectivity and a host of other compatibility features. Some of the best gaming notebooks include Alienware Aurora, Dell XPS M170, and Rock Xtreme CTX PRO and etc.

If you are looking for just an economic replacement for your desktop and you do not want to spend on a high-end notebook, then you can select from a variety of models offered by Acer, Apple, Dell, Fujitsu, HP, Samsung, Sony and Toshiba. These notebooks are fashioned to be used at a fixed location and weigh up to 13 pounds, so they are not very convenient if you have to travel a lot. They generally have bigger screen sizes and lower battery life.

Apart from the notebooks mentioned above you can also pick tablet PCs, transportables, high-end personal digital assistants (PDAs), handheld computers, or smart phones. These are mobile devices that you can carry with you wherever you go, if mobility is all you are looking for.

Cell Phone Insurance - Look Before You Buy

Our cell phones are a life line, a work tool, and in some cases, the tie that binds families. To be without a cell phone is unimaginable for many but it is a reality that they are faced with at some time as record numbers of handsets are lost, stolen, or rendered useless each year. However, in a nation that attempts to insure every possession, cell phone insurance is available.

Numerous insurers have popped up in recent years promising to end the turmoil caused by the unexpected absence of these handy devices. These companies reassure us that we won't go more than a matter of hours when a cell phone is stolen as they strive to quickly resolve claims and replace our valuable goods. But is this insurance really cost effective? Does it provide the service that consumers anticipate? Potential buyers need to take the time to seek out the details of a policy before deciding that such insurance is a solution to the issue of a cell phone gone missing or bad.

When reviewing a cell phone insurance policy, buyers should consider a few things:

Consider the cost of the coverage.

This includes the monthly payments times the number of months the owner anticipates having the phone. For instance, a $5/month policy held on a phone that is owned for 3 years would total $180. That is $5 x 36 months = $180. Now the potential buyer must also factor in any deductible. For our example lets say there is a $50 deductible. The new total of $230 represents what the buyer would actually be paying if indeed their phone had to be replaced. Consumers need to compare the cost of a new, equivalent cell phone compared to the cost of the coverage. If they can obtain a new phone on their own for nearly the same amount as the cost of the policy, they are better off forgoing the insurance.

How are cell phones replaced?

Is there a guarantee that the phone will be replaced with a model of equivalent or better value? A guarantee that the phone will be new rather than refurbished? Is there language assuring the time frame in which the phone will be replaced? These types of questions will help determine whether or not the service will meet the needs for immediacy in obtaining a replacement and if the replacement will be inferior or equivalent to the original equipment.

What does the cell phone insurance policy cover?

Does the policy apply to cell phone theft, cell phone loss, and significant damage? It is important to know which situations are covered and which are most likely to occur. If the policy does not cover the situations that a particular buyer is most concerned with, then the policy is useless to them. Many policies will differentiate between loss and theft; sometimes requiring a police report for thefts.

Know what the cellular provider can do in these instances

Some cellular providers are willing to help replace a damaged or missing cell phone that a user has had for more than a year. In some cases, a replacement will be provided or discounted, minimizing the need for the additional protection of cell phone insurance.

Like any type of insurance coverage, cell phone insurance could provide significant assistance in quickly replacing a vital device that an owner can not afford to replace in some circumstances. However, in many instances it is merely an added expense. Consumers need to carefully review the policy to determine whether or not it offers the type of protection they need for their cell phone.

Cell Phones - Tips for Better Pictures

Camera capabilities have become common on cell phones and, for some users, these camera phones are their only means of capturing and sharing images. Certainly, the camera within a cell phone is readily available and portable, making them a good option for more spontaneous photography. In addition, they are less conspicuous than all but the more compact stand alone digital cameras, allowing users to take more candid shots easily.

Cell phone cameras also have a reputation for their limitations however. From slower shutter speeds that make blurry pictures likely, lack of manual control to adjust exposure, white balance, focus, and so forth, to the common lack of high quality lenses, CMOS sensors, and the megapixels necessary for sharp images, the average camera phone often doesn't compete well with stand alone digital cameras for producing high quality images for print.

With recent advancements in the design of cell phone cameras however, consumers can now find devices that are capable of creating far better images, even in the printed form. By choosing the right camera phone and employing a few basic photographic techniques, the images users create are usually quite acceptable.

For users who want to be able to print sharp, detailed 5x7 images, there are a few things to consider when making a camera phone purchase:

• Get better resolution. Until recently a 1.3 megapixel camera was the best available. Now cell phones that offer a camera with a CMOS sensor and 3 megapixels, or more, are available.

• Get a higher quality lens, and protect it. Some cell phone cameras offer better lenses; a Carl Zeiss lens for instance is highly regarded. Getting a lens cover to protect the lens from scratches, dirt, and dust can be important too; cell phones are often thrown into situations and locations that put them at risk for damage.

• Get features to reduce camera shake. Cell phones are small, thus more difficult to hold steady. Slower shutter speeds further exacerbate the need for a very steady hand. A camera with optical image stabilization can help to reduce blurriness and one that the user can securely grip is a bonus as well.

• Get optical zoom. Many cell phone cameras offer digital zoom. Better cameras offer optical zoom. When photographers can't step close to a subject, optical zoom is the answer without reducing image quality.

• Get features that allow some manual control. Great photographs often require photographers to adjust exposure, white balance, and focus. At a minimum, a user should have the option of turning off the flash.


• Get an LCD that helps in framing the scene that is to be photographed. A screen with a large viewing area is important in setting up shots. Good viewability should be checked, especially in sunlight. Potential buyers should pick the cell phone up and try framing a few shots indoors, and outdoors if possible.

Once a good camera phone is in hand, users then need to heed a few critical photographic rules that are particularly pertinent when shooting with small cell phone devices:

• Use high resolution settings on the camera phone in case prints are desired later; prints require higher resolution than sharing images on a screen.

• Keep the camera steady. Try holding the cell phone with both hands, bracing arms/elbows against the body. Try bracing against a doorway, a tree, a table, and so forth for added stability. It can also be useful to remain stationary for a few seconds after pressing the button to assure that the camera has completed the process of capturing the image.

• Get close to the subject. Camera phones are better at capturing nearby subjects rather than landscapes and such. Avoid using digital zoom.

• Keep the lens clean. Cell phones, as noted before, tend to be tossed around and accumulate a lot of fingerprints, dirt, and scratches without extra care.

• Lighting is critical as in all photography. Camera phones are better adapted for outdoor use in general. Avoid backlighting subjects; side lighting is generally best.


Cell phone cameras are improving and, although not yet competitive with most stand alone digital cameras, are capable of producing very acceptable images for the average user. For those who value the photographic ability of their cell phone, good options are available if they know how to make the right choice and are able to compensate for their limitations with good photographic techniques.

Kamis, 05 Januari 2012

Revive AIR-CON Applications

Almost all the today's know-how in recent times implement electric power applications to help you carry through ones own options. Electric power applications contain magnets which will bring in source of electricity. Magnets boost rotational motion through agreement with the regulations in magnets, at which a few magnets which use conflicting edges might usually tend to bring in concert. That charm in magnets releases rotational motion.

That motion in electric power applications fulfill simply because ones own options. Equipments which use applications can be vacuum cleaners, automatic washers, blenders, fanatics, several alternative activities. You will also find home pc instruments which use applications, which includes BLU-RAY and CD-ROM online players and even disc forces.

Electric power applications are by and large cut inside three or more segments -Alternating Up-to-date (AIR-CON) applications, Steer Up-to-date (DC) applications, and even simple. AIR-CON applications alter from DC applications simply because it won't operated once joined, the exact same option considering the DC applications. Then again, that simple functions through choose to AIR-CON and DC up-to-date.

That subcategories in AIR-CON can be particular point and even three or more years. That particular point AIR-CON will be an electrical power give which can be very popularly used in the house while it contains slighter currents.

AIR-CON is commonly employed on using small-scale construction equipments. They have perhaps extraordinary application skills simply because AIR-CON electrical power give would not want to contain sizeable up-to-date. That DC electrical power give is certainly caused by utilized for crops because could very well work with sizeable probability in business and even options. DC can easily deliver wide range of electrical power give.

Considering the fact that AIR-CON is commonly utilized for family home functions, as a consequence the application discusses a whole lot of loved ones materials. That is why how come you will find a sought after demand designed for revive AIR-CON applications.

Difficult AIR-CON applications on you'll need for that protection in devices which will implemented AIR-CON electrical power give. Nevertheless AIR-CON can be a minute climb in ac current, but the application will require source of electricity, then it truly assumed. Possibly even the tiniest machines with source of electricity would definitely give you this brief circuit, the great situation.

An important poor AC motor should really be exposed proper decent revive AIR-CON applications expertise at once, with the intention that conditions will be avoidable as a result of difficult. Electrical power issues which can not even end up mastered during an preceding precious time can potentially wipe out all the machines.

Electric power applications are necessary to help you formation. It is therefore very important which will product and even protection is without a doubt earning a living competent. So you can get top notch product and even very good makes for it trade, you have got to to start with learn about that "ins and even out" belonging to the product internet business specifically for electro-mechanical system.

The ideal way for you to thrive as well as have very good product is without a doubt to see the best accomplice. In cases where you need an email finder service accomplice on Eu and Intercontinental one entirely have got to have a look at much of our websites blog! Individuals small business you can get the education that you really preferably need http://www.newbharat.com.

Rabu, 04 Januari 2012

1/4 Telecommunication Articles at ArticleGeek.com

     
    Telecommunication Articles at ArticleGeek.com    
   
Stop Unwanted Calls and Messages to Cell Phone
January 4, 2012 at 8:59 AM
 
Have you ever received unwanted calls on your cell phone? There is an annoyance and an expense to unsolicited marketing calls and text messages. How can you take control? We have a few tips to help.
   
   
Prepaid Standard Cell Phone Services
January 4, 2012 at 8:59 AM
 
This article explains the differences between the prepaid and standard cell phone services, providing information about the advantages of each service and which one is best to suit someone's lifestyle.
   
   
Latest Telecommunication Articles at ArticleGeek.com
January 4, 2012 at 8:59 AM
 
Read the latest Telecommunication Articles from ArticleGeek.com
   
   
IMS SIP: The Right Solution for Widespread Next Generation Networks
January 4, 2012 at 8:59 AM
 
A description of the key elements comprising IMS SIP technology, including its architecture, network components and signaling protocols.
   
   
How to Shop for Cell Phone Plans - Text Messaging Costs
January 4, 2012 at 8:59 AM
 
Although very popular, text messaging has often resulted in exorbitant bills. Recently, cellular providers have begun providing an option that may be more cost effective: unlimited texting plans. Learn what to look for in such plans.
   
   
GPS Cell Phone
January 4, 2012 at 8:59 AM
 
This article explains the GPS cell phone tracking service, as an important aid in locating cell phone users in emergency situations. Also it talks about user's privacy issues and how the law is dealing with it.
   
   
Digital City (Part 2 of 2)
January 4, 2012 at 8:59 AM
 
Digital cities are no longer just a dream. They are possible and PPP will see them become a reality for the benefit of all citizens of this nation. How long it will take, depends on the vigour and determination of both government and private organisations.
   
   
Digital City (Part 1 of 2)
January 4, 2012 at 8:59 AM
 
The idea of a fully 'connected' and integrated digital city, with a plethora of online services for its citizens, sounds ultra-futuristic and like a pipe dream. The local telecoms and IT industry has its own views.
   
   
Competition is Essential
January 4, 2012 at 8:59 AM
 
Broadband penetration in households varies globally, with Korea being the world leader with a penetration of 68%, the USA having 28%, and the UK 16%. SA shamefully has a broadband household penetration of 0.3%. The question posed here is why South Africa is so far behind...
   
   
Committing to a Cell Phone Plan - the Critical First Days
January 4, 2012 at 8:59 AM
 
Ever purchase a product or service and been severely disappointed? This is particularly distasteful with something like a cell phone plan that last 2 years. We will alert you to the best method available to thwart getting stuck with a bad plan.
   
   
Cell Phones and Land Lines - Get the Best of Both Worlds
January 4, 2012 at 8:59 AM
 
Your landline gives you excellent call quality. Your cell phone offers you great savings on long distance. Don't you wish you could have the advantage of receiving your cellular calls on your landline? You can, and we will tell you how.
   
   
Cell Phones - Tips for Better Pictures
January 4, 2012 at 8:59 AM
 
More people are becoming dependent upon their cell phone for capturing images. We will tell you what to look for when picking out a camera phone and how to take better photographs with these handy devices.
   
   
Cell Phone Plans That Make You Go Hmmm
January 4, 2012 at 8:59 AM
 
Cell phone plans across the globe vary a great deal. Some say that cell phone plans in the US are more costly. However, there are some advantages to the cell phone plans in the US which may balance the difference.
   
   
Cell Phone Plans - When Minutes Count
January 4, 2012 at 8:59 AM
 
Understanding how cell phone minutes are billed can save users a great deal of expense on their monthly bill. We will explain the terminology that is common in cell phone plans.
   
   
Cell Phone Insurance - Look Before You Buy
January 4, 2012 at 8:59 AM
 
With the risk of losing or having your cell phone stolen, have you ever wondered if cell phone insurance is a good idea. Possibly it is in some instances, but evaluating what it really offers may be eye opening.
   
   
Cell Phone in Every Pocket
January 4, 2012 at 8:59 AM
 
This article describes the importance of cell phones in our everyday lives and the etiquettes one should follow in different occasions.
   
   
Cell Phone Data Service Plans
January 4, 2012 at 8:59 AM
 
Purchasing a web enabled cell phone is only one step in the process of getting the efficiency smartphones can provide busy, time limited people. We will tip you off on some important things to consider when choosing a data plan.
   
   
Broadband Bullfight Heats Up
January 4, 2012 at 8:59 AM
 
You've probably already heard that VoIP could cut a substantial chunk off your company's monthly telecoms bill, and that there is more than one provider that offers the service. Both these facts are true. It so easy for you to implement VoIP that you'll barely realise it's happened until your vastly reduced phone bill arrives.
   
     
 
This email was sent to ibnu.it.labit@blogger.com.
Delivered by Feed My Inbox
PO Box 682532 Franklin, TN 37068
Create Account
Unsubscribe Here Feed My Inbox
 
     

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Hot Sonakshi Sinha, Car Price in India