Effizienter Weg, um große tab-getrennte txt-Datei?

Ich habe eine tab-getrennte txt-Datei mit 500K Datensätze. Ich bin mit dem code unten, um Daten zu Lesen auf dataset. Mit 50K es funktioniert gut, aber 500K, es gibt "Ausnahme vom Typ 'System.OutOfMemoryException " wurde ausgelöst."

Was ist die effizientere Art und Weise zu Lesen, große tab-getrennte Daten?
Oder wie dieses Problem zu beheben? Bitte geben Sie mir ein Beispiel

public DataSet DataToDataSet(string fullpath, string file)
{
    string sql = "SELECT * FROM " + file; //Read all the data
    OleDbConnection connection = new OleDbConnection //Connection
                  ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fullpath + ";"
                   + "Extended Properties=\"text;HDR=YES;FMT=Delimited\"");
    OleDbDataAdapter ole = new OleDbDataAdapter(sql, connection); //Load the data into the adapter
    DataSet dataset = new DataSet(); //To hold the data
    ole.Fill(dataset); //Fill the dataset with the data from the adapter
    connection.Close(); //Close the connection
    connection.Dispose(); //Dispose of the connection
    ole.Dispose(); //Get rid of the adapter
    return dataset;
}

InformationsquelleAutor Michael Born | 2011-05-18

Schreibe einen Kommentar