[thelist] iterate through SQL results without knowing columnnames

Anthony Baratta anthony at baratta.com
Thu Aug 9 18:49:14 CDT 2007


here's an quick non-working example using the function call I sent you:

 FileInfo scanLog = new FileInfo(sLog);

DataSet dsDBData = db.execSPForDataSet("[SP_GET_TABLE_DATA]", "dataSetName", htParameters);
        DataColumnCollection dcColumns = dsDBData.Tables[0].Columns;
        foreach(DataRow myRow in dsDBData.Tables[0].Rows)
        {
            string sText;
            foreach( DataColumn dColumn in dcColumns)
            {
                sText += "|" + myRow[dColumn.ColumnName.ToString()].ToString();
            }

            using (StreamWriter sw = scanLog.AppendText())
            {
                sw.WriteLine(sText);
            }


-----Original message-----
From: "Joel D Canfield" joel at streamliine.com
Date: Thu, 09 Aug 2007 16:29:10 -0700
To: "Anthony Baratta" anthony at baratta.com, thelist at lists.evolt.org
Subject: RE: [thelist] iterate through SQL results without knowing columnnames

> > Here's an example from my code base that opens an SQL Adapter 
> > Connection and dumps that to a dataset object. Then with the 
> > dataset object you can do your business with the data returned.
> 
> er, how? is there a way to just write the contents of the dataset to a
> text file? I'm comfortable with creating, writing, appending
> to/from/with text files, just don't know how to get the dataset from an
> object to text to put in the file.
> 
> thanks, yet once again
> 
> joel
> 



More information about the thelist mailing list