我的代码遇到问题。我想更新访问数据库中的信息,但它会在行conn->打开时不断发现错误,并且不会提供任何错误信息。
cout << "Please enter file name... ";
cin >> fileName;
String^ name = gcnew String(fileName.c_str());
String^ sqlstr = "UPDATE [Saved] SET Name = '"+name+"' WHERE ID = 1";
OleDbConnection^ conn = nullptr;
OleDbCommand^ cmd = nullptr;
try {
//Create and open database connection.
conn = gcnew OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = F:\WWTMrWolf_Prototype_Demo\Debug\WTMrWolf_P_D_Database.mdb");
conn->Open();
cmd = gcnew OleDbCommand(sqlstr, conn);
OleDbDataReader^ reader = cmd->ExecuteReader(System::Data::CommandBehavior::CloseConnection);
while (reader->Read())
{
printf("File ") +reader["Name"]->ToString()+ (" created");
}
}
catch (Exception^ ex)
{
printf("Error: ") + ex->ToString();
system("Pause");
exit(0);
}
return fileName;
输出:&#34;错误:按任意键继续...&#34;