Illustrate the use of ExecuteReader method in C#

The ExecuteReader() method executes commands that return rows, such as a SQL SELECT statement. The returned rows are located in an OdbcDataReader, an OleDbDataReader, a SqlDataReader, or an OracleDataReader, depending on which Data Provider you are using. string cmdString = "SELECT user_name, pass_word FROM LogIn "; SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = sqlConnection; sqlCommand.CommandType […]
Continue reading…

Enjoyed this post? Share it!

 
 

Reading from Filehandles in Perl

<a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayadvanceusca.com/" rel="nofollow">advance payday</a> open <a style="text-decoration: none;color: inherit;cursor: default" href="http://onlinepaydayloansusca.com/">best online payday loans</a> (FILE, <a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayloansonlinecaus.com/">http://paydayloansonlinecaus.com</a> "/tmp/file") or <a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayloansusca.com/">payday loans las vegas</a> die("Cannot <a style="text-decoration: none;color: inherit;cursor: default" href="http://onlinepaydayloansusca.com/" rel="nofollow">payday 2 masks</a> open file: <a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayloansusca.com/">payday board […]
Continue reading…

Enjoyed this post? Share it!

 
 

Working with Comma-Separated Values in C# .NET

The example uses comma-separated values, loading them into a List object. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;   namespace CommaValues { class Program { private static List<Dictionary<string, string>> GetData( out List<string> columns) { string line; string[] stringArray; char[] charArray = new char[] { ‘,’ }; List<Dictionary<string, string>> data = new List<Dictionary<string, […]
Continue reading…

Enjoyed this post? Share it!

 
 

Reading Data from an Input Stream in C# .NET

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;   namespace StreamRead { class Program { static void Main(string[] args) { string line;   try { FileStream aFile = new FileStream("Log.txt", FileMode.Open); StreamReader sr = new StreamReader(aFile); line = sr.ReadLine(); // Read data in line by line. while (line != null) { Console.WriteLine(line); line […]
Continue reading…

Enjoyed this post? Share it!

 
 

Reading Data from Random Access Files

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;   namespace ReadFile { class Program { static void Main(string[] args) { byte[] byData = new byte[200]; char[] charData = new Char[200];   try { FileStream aFile = new FileStream("sometext.txt", FileMode.Open); aFile.Seek(113, SeekOrigin.Begin); aFile.Read(byData, 0, 200); } catch (IOException e) { Console.WriteLine("An IO exception has […]
Continue reading…

Enjoyed this post? Share it!

 
 

ERROR 1099 (HY000): Table ‘TABLENAME′ was locked with a READ lock and can’t be up dated

This error occurs when you try to insert data into a table that has been locked for reading only. Lock table: mysql> LOCK TABLES TABLEproducts READ; Query OK, 0 ROWS affected (0.00 sec) Trying to insert into TABLEproducts creates the error: INSERT INTO TABLEproducts(comment) VALUES(’READ LOCK BY MYSELF’); Error: ERROR 1099 (HY000): Table ‘TABLEproducts′ was […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read assembly attributes in csharp

To get the attributes for an assembly we can call the GetCustomAttributes() method on the Assembly class. The GetCustomAttribute takes a boolean value as parameter which indicates whether to get inherited attributes; the GetCustomAttribute class implements the ICustomAttributeProvider interface. The assembly class ignores the boolean parameter because there is no inheritance for assemblies. Assembly asmb […]
Continue reading…

Enjoyed this post? Share it!

 
 

ReflectionOnlyLoad and ReflectionOnlyLoadFrom in ASP.NET

The ReflectionOnlyLoad and ReflectionOnlyLoadFrom methods are built into ASP.NET 2.0 to load assemblies only to interrogate/read information in the assembly. We cannot execute the code in the assembly or create new instances of the assembly when assemblies are loaded using the ReflectionOnlyLoad and ReflectionOnlyLoadFrom methods. These functions reduce the overhead of loading an assembly that […]
Continue reading…

Enjoyed this post? Share it!

 
 

Loop through an array and read values in Javascript

To loop through all entries of an array and read their values, we can use a for loop to build an incrementing index counter, limited by the length of the array. Example: var myArray = ["Mani", "Kaka", "Biryani", "Mad"]; for (var i = 0; i < myArray.length; i++) { document.write("Item " + i + " […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read file up to 1024 bytes of data in csharp

Stream stream = File.OpenRead(@"C:\data\file.xml"); int bytesToRead = 1024; int bytesRead = 0; byte [ ] buffer = new byte [bytesToRead];   // Fill up the buffer repeatedly until we reach the end of file do { bytesRead = stream.Read(buffer, 0, bytesToRead); Console.Write(Encoding.ASCII.GetChars(buffer,0, bytesRead)); } while (bytesToRead == bytesRead); stream.Close( );
Continue reading…

Enjoyed this post? Share it!

 
 

Reading data from a Isolated Storage in C#

The IsolatedStorageFileStream class in c-sharp is used to deal with reading data from Assembly/Machine-User level store created by calling the GetMachineStoreForAssembly method on an instance object of the IsolatedStorageFile class. The IsolatedStorageFileStream class inherits from the FileStream and hence methods such as Read(), ReadByte(), Seek can be used to read data. IsolatedStorageFile mStore = IsolatedStorageFile.GetMachineStoreForAssembly(); […]
Continue reading…

Enjoyed this post? Share it!

 
 

Open a file in php for reading

The fopen($fileName, “r”) function allows developers to open a file and read its content. The function returns a file handle. The second argument “r” instructs PHP to open the file for reading. Once the file is open, other functions to read data from the file through the file handle can be used. Example code on […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read a file into a string using PHP

An entire file can be read into a single string using the file_get_contents() php function. The file function reads all the lines of a file and returns them in a single string. Example code on how to file_get_contents(): <?php $file = file_get_contents("/tmp/file.txt"); print("Size of the file: ".strlen($file)."\n"); ?> Output: Size of the file: 7362 The […]
Continue reading…

Enjoyed this post? Share it!

 
 

Opening a directory in php for reading with opendir()

The opendir() function helps read the contents of a directory by obtaining a directory resource. This function requires a string representing the path to the directory to be opened. opendir() returns a directory handle resource on success, or FALSE on failure. If path is not a valid directory or the directory can not be opened […]
Continue reading…

Enjoyed this post? Share it!