我有一个使用 C# 读取的 sql08 数据库表。其中一列(College)包含一些数据有逗号的数据:Miami, FL
或Miami, OH
,而有些则没有:USC
。我的输出 .csv 将数据从包含行的逗号向右移动一列。我希望我的输出包含Miami,FL
一个字段:|Miami,FL|
不是|Miami| |FL|
myWriter.WriteLine("Player, Position, Current Team, College");
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("Select * FROM FootballRoster", myConnection);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
string myPlayer = myReader.GetString(0);
string myPosition = myReader.GetString(1);
string myCurTeam = myReader.GetString(2);
string myCollege = myReader.GetString(3);
myWriter.WriteLine("{0}, {1}, {2}, {3},", myPlayer, myPosition, myCurTeam, myCollege);
}