开发者

how will read csv file into dataset? [closed]

开发者 https://www.devze.com 2022-12-27 18:10 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague开发者_如何学C, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form.
It's difficult to tell what is being asked here. This question is ambiguous, vague开发者_如何学C, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

i want to read csv file using c#.


Microsoft has standard driver for text file MS-Text driver. You can use and load effortlessly.

string strConn = @"Driver={Microsoft Text Driver (*.txt; *.csv)};" +
  "Dbq=C:;Extensions=csv,txt";

try
{
  OdbcConnection objCSV = new OdbcConnection(strConn);
  objCSV.Open();

  OdbcCommand oCmd = new OdbcCommand("select column1,column2 " +
    "from THECSVFILE.CSV", objCSV);
  OdbcDataReader oDR = oCmd.ExecuteReader();

  while (oDR.read())
  {
    // Do something
  }
  oDR.Close();
  oCmd.Dispose();
  objCSV.Close();
}
catch {}


You could try out A Fast CSV Reader

It's a CodeProject project and should fit your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号