Actually, I only posted a small portion of the code. I am using the streamreader object to read my txt file. I am having a problem with assigning the contents of the text file to a column of my dataset. There is something wrong with this line of code "ds.Tables[0].Rows[RowCoun
filetoread = Server.MapPath("test2.txt"
StreamReader reader = new StreamReader(filetoread);
for (string readcontents = reader.ReadLine(); readcontents != null; readcontents = reader.ReadLine())
{
char [] delimiter = textdelimiter.ToCharArray(
splitout = readcontents;
String [] split = null;
split = readcontents.Split(delimit
ColCounter = 0;
foreach (string a in split)
{
ds.Tables[0].Rows[RowCount
ColCounter++;
}
RowCounter++;
Main Topics
Browse All Topics





by: Coolhand2120Posted on 2005-03-05 at 16:33:56ID: 13468555
I had this probelm too, you must change your select statement to read somthing more like :
eObject("A DODB.Conne ction") xt" you must have the FILENAME of the file you're trying to read from "ADODB.Rec ordSet")
strPath = Server.MapPath("/")
set objConnection=Server.Creat
objConnection.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & strPath & "\somedirectory\" & ";Extensions=asc,csv,tab,t
strSQL = "Select * From " & uploadname '<--------------------Here
set objRS=Server.CreateObject(
objRS.Open strSQL, objConnection,3,3
arrRows=objRS.GetRows()
set objRS = nothing
set objConnection = nothing
You don't have to use this method, just understand that the SQL statement must contain the file name of the file you are parseing. If you're using an upload componet you can usualy find this value somewhere in it's object collection.
Sorry my only example is in VB, but the object syntax is the same.
-Coolhand2120