我正在尝试将SQL数据库表导出到文本文件。我可以创建该文件,但它是空白的。我认为问题出在Fill()上,但我不确定。任何帮助都会很棒。
SqlCommand^ myCommand = gcnew SqlCommand("SELECT * FROM [CSC 289].dbo.Inventory ;", myCon);
SqlDataReader^ myReader;
StreamWriter^ sw = gcnew StreamWriter("File.txt");
SqlDataAdapter^da = gcnew SqlDataAdapter();
da -> SelectCommand = myCommand;
DataTable^ dt = gcnew DataTable();
for each(DataRow^ row in dt -> Rows)
{
for each(DataColumn^ col in dt -> Columns)
{
da -> Fill(dt);
sw -> WriteLine(dt);
}
}
sw -> Close();
delete sw;