C# .NET - how to use getstring in datareader - Asked By chitra ganapathy on 21-Jul-12 06:10 AM

hi, i want to select 1st 5 character and assign in stringarray, i tried the following code, but it showing me error
           public string[] str;
           OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
               str = dr[0].GetString(4).tostring();
            }.
i want to select first 5 character of each row and assign to str. Suggest me some idea plz.
Peter Bromberg replied to chitra ganapathy on 21-Jul-12 09:44 AM
   public string str;
           OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
               str = dr[0].GetString().SubString(0,4);
            }.