Tag Archives: read

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 = … Continue reading

Posted in C# ADO.NET | Tagged , | Leave a comment

Reading from Filehandles in Perl

open (FILE, "/tmp/file") or die("Cannot open file: $!"); while (<FILE>) { chomp; print "The line just read was: $_\n"; }

Posted in Perl File Handling | Tagged , | Leave a comment

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[] … Continue reading

Posted in C# File Handling | Tagged , , | 1 Comment

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 = … Continue reading

Posted in C# File Handling | Tagged , | Leave a comment

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", … Continue reading

Posted in C# File Handling | Tagged , | Leave a comment

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 … Continue reading

Posted in MySql Errors | Tagged , , | Leave a comment

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 … Continue reading

Posted in C# ASP.NET Reflection | Tagged , , | Leave a comment

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 … Continue reading

Posted in C# ASP.NET Reflection | Tagged , , | Leave a comment

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 … Continue reading

Posted in Language basics | Tagged , , | Leave a comment

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, … Continue reading

Posted in C# Streams | Tagged , , | Leave a comment

Read complete POST data in PHP

If a developer wants to read the complete body of a post request and not just the parsed data that PHP puts in the super global array $_POST, we can use the php://input stream. This can be used to to … Continue reading

Posted in Language Basics | Tagged , , , | Leave a comment

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 … Continue reading

Posted in C# Streams | Tagged , , | Leave a comment

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 … Continue reading

Posted in PHP File Handling | Tagged , | Leave a comment

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 … Continue reading

Posted in PHP File Handling | Tagged , , | Leave a comment

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 … Continue reading

Posted in PHP File Handling | Tagged , | Leave a comment