How to read specific characters from a text file

Use namespace System.IO VB.NET Dim fs As New System.IO.FileStream(Server.MapPath(‘1.txt’), IO.FileMode.Open) Dim buffer(5) As Byte ’ 5=> number of characters to be read fs.Read(buffer, 0, 5) fs.Close() Dim filechars() As Char = System.Text.Encoding.ASCII.GetChars(buffer) Dim filestring As String = New String(filechars) Response.Write(filestring) C# FileStream fs =new FileStream(Server.MapPath(‘1.txt’), FileMode.Open); Byte[] buffer= new byte [5] ; //5 => Number of characters to be read fs.Read(buffer, 0, 5); fs.Close(); Char[] filechars = System.Text.Encoding.ASCII.GetChars(buffer); string filestring = new String(filechars); Response.Write(filestring);

Does JavaScript support hashtables/ hash tables or dictionary type data structures?

All Objects in JavaScript implicitly support hash table like syntax by virtue of behaving as Associative Arrays. Properties of an object can be accessed in 2 ways as shown below: object.property = value; object[‘property’] = value; So, when used in a hash table like syntax as shown above, you will be simply creating dynamic properties and assigning values to those properties.

How to get the count of items in a dataReader

VB.NET Dim mycn As New SqlConnection(‘server=localhost;uid=sa;password=;database=northwind;’) Dim mycmd As New SqlCommand(‘Select * from Products’, mycn) mycn.Open() Dim dr As SqlDataReader = mycmd.ExecuteReader Dim i As Integer While dr.Read i += 1 End While Response.Write(‘Count of Records : ‘ & i) C# SqlConnection mycn =new SqlConnection(‘server=localhost;uid=sa;password=;database=northwind;’); SqlCommand mycmd = new SqlCommand (‘Select * from Products’, mycn); mycn.Open(); SqlDataReader dr = mycmd.ExecuteReader(); int i=0; while(dr.Read()) { i+=1; } Response.Write(‘Count of Records : ‘ + i.ToString());

How to display multiple records using DataTable.Select

Use namespace System.Data.OleDb VB.NET Dim myConnection As New OleDbConnection(‘Provider=SQLOLEDB.1;Data Source=localhost;database=northwind;User Id=sa;Password=;’) Dim myda As New OleDbDataAdapter(‘Select * from Orders’, myConnection) Dim ds = New DataSet myda.Fill(ds, ‘table’) Dim dr() As DataRow Dim id As String = ‘ROMEY’ ’ ‘Field with id ROMEY has more than one records found Dim sel As String = ‘customerid=’’ + id + ‘’’ dr = ds.Tables(0).Select(sel) Dim i As Integer For i = 0 To (dr.GetUpperBound(0)) – 1 Response.Write((dr(i)(‘Orderid’).ToString() + ControlChars.Tab + dr(i)(‘Customerid’).ToString() + ControlChars.Tab + dr(i)(‘Freight’).ToString() + ‘ ‘)) Next C# OleDbConnection myConnection = new OleDbConnection(‘Provider=SQLOLEDB.1;Data Source=localhost;database=northwind;User Id=sa;Password=;’); OleDbDataAdapter myda= new OleDbDataAdapter (‘Select * from Orders’, myConnection); System.Data.DataSet ds= new DataSet (); myda.Fill (ds,’table’); DataRow[] dr ; string id =’ROMEY’;// ‘Field with id ROMEY has more than one records found string sel =’customerid=’’+ id + ‘’’; dr = ds.Tables [0].Select (sel); int i; for(i=0;i<dr.getupperbound(0);i++) {=”” response.write=”” (dr[i][‘orderid’].tostring()=”” +=”” ‘\t’=”” dr[i][‘customerid’].tostring()=”” dr[i][‘freight’].tostring=”” ()=”” ‘<br=””>’); } </dr.getupperbound(0);i++)>