odbc| data
CSV files, commonly known as "comma-delimited files", the way to read the CSV file can be read by using iostream ...
I thought this one method, hehe. Until one day. See the connection of the text on the www.ConnectionStrings.com
String:
Text
- Odbc
- Standard:
"Driver={microsoft Text Driver (*.txt; *.csv)};D bq=c:\txtfilesfolder\; Extensions=asc,csv,tab,txt; "
- OLE DB
- Standard:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtfilesfolder\; Extended properties= "" text; Hdr=yes; Fmt=delimited "" ""
hdr=yes; "indicates that
" the "the" the "the" the "the" the "the". Contains ColumnNames
- Standard:
"Driver={microsoft Text Driver (*.txt; *.csv)};D bq=c:\txtfilesfolder\; Extensions=asc,csv,tab,txt; "
- OLE DB
- Standard:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtfilesfolder\; Extended properties= "" text; Hdr=yes; Fmt=delimited "" ""
hdr=yes; "indicates that
" the "the" the "the" the "the" the "the". Contains ColumnNames
- Standard:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtfilesfolder\; Extended properties= "" text; Hdr=yes; Fmt=delimited "" ""
hdr=yes; "indicates that
" the "the" the "the" the "the" the "the". Contains ColumnNames
Isn't there a csv here? Oh, you can try Ah, the test results are very good. You can use ODBC to connect. csv as a database,
It feels good. (OLE DB's unsuccessful, will properties=text change to Properties=csv does not work, is not support, or I write wrong?)
So here's a way to provide. (Certainly not my invention OH), use ODBC connection way, through DataAdapter directly will
Data to quickly import dataset, very convenient. The method is as follows:
Public DataSet getdatasetfromcsv (string filePath, String fileName)
{
String strconn = @ "Driver={microsoft Text Driver (*.txt; *.csv)};D bq=";
strconn + = FilePath; FilePath, for Example:c:\
strconn + = "; Extensions=asc,csv,tab,txt; ";
OdbcConnection objconn = new OdbcConnection (strconn);
DataSet dscsv = new DataSet ();
Try
{
String strSQL = "SELECT * from" + fileName; FileName, for Example:1.csv
OdbcDataAdapter odbccsvdataadapter = new OdbcDataAdapter (strSQL, objconn);
Odbccsvdataadapter.fill (dscsv);
return dscsv;
}
catch (Exception ex)
{
Throw ex;
}
}