问题描述
因此,我试图使用MySqlDataReader从数据库中获取数据.我知道数据库确实可以响应(从我的程序中正常插入,删除和更新所有工作).
So I'm trying to use a MySqlDataReader to acquire data from my database. I know that the database does in fact respond (insert, delete, and update all work fine from my program).
using (MySqlConnection conn = new MySqlConnection(connectionString))
{
// Open a connection
conn.Open();
MySqlCommand command = conn.CreateCommand();
command.CommandText = "select * from cs3500_u0848199.PairedGames";
// Execute the command and cycle through the DataReader object
using (MySqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{ /*do something here*/}
}
}
问题似乎并不出在命令本身上,因为该命令在MySQL工作台中有效.无论如何,在执行这一行代码后
The problem does not appear to be with the command itself, as the command works in the MySQL workbench. Anyways, upon executing this line of code
using (MySqlConnection conn = new MySqlConnection(connectionString))
VS调试器注意到抛出了以下异常
the VS debugger notes that the following exception was thrown
由于我在此代码中未使用Guid,因此真的不确定为什么会告诉我有关Guid格式的信息.任何帮助将不胜感激.
Really unsure as to why it's telling me about the guid format since i'm not using Guids in this code.Any help will be greatly appreciated.
推荐答案
看来,将;old guids=true;
附加到连接字符串可以解决此问题.
it appears that appending ;old guids=true;
to the connection string resolved the issue.
这篇关于MySqlCommand.ExecuteReader()在初始化时引发System.Format异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!