gpt4 book ai didi

时间:2019-03-17 标签:c#-System.FormatException: 'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'

转载 作者:行者123 更新时间:2023-12-02 20:13:48 27 4
gpt4 key购买 nike

当我的数据库离线时,我没有遇到这个错误。我刚刚使用 db4free.net 使我的数据库联机。

每次登录都会出现此错误。有人能指出哪里出了问题吗?

private void btnLogIn_Click(object sender, EventArgs e)
{
string query = "select * from tbl_accounts where username='" + tbxUsername.Text + "' and password='" + tbxPassword.Text + "'";
MySqlCommand command = new MySqlCommand(query, connection);
MySqlDataAdapter da = new MySqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);

try
{
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];

if (dt.Rows.Count > 0)
{
employee_id = (dr["employee_id"].ToString().PadLeft(4, '0'));
fullname = (dr["account_firstname"] + " " + dr["account_lastname"]).ToString();
this.Invoke(new Action(() =>
{
connection.Open();
command.ExecuteNonQuery();
connection.Close();
this.Close();
th = new Thread(openNewForm);
th.SetApartmentState(ApartmentState.STA);
th.Start();
}));
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

这是错误:

Exception screenshot

Updated: Here is my connection string:

MySqlConnection connection = new MySqlConnection("datasource=db4free.net;Convert Zero Datetime=True;SslMode=none");

最佳答案

距 OP 日期几乎正好 1 年,我在使用 NuGet 包 MySQL.Data 进行实验时遇到了相同的错误

我在这个 earlier StackOverflow post 的评论中找到了解决方法

基本上,您可以通过添加 OldGuids=True; 作为 MySQL 数据库连接字符串的一部分来避免错误,正如 @noontz 提到的。

但是,正如 @BradleyGrainger 所指出的,请注意,通过执行此操作,任何 BINARY(16) 列都将作为 Guid 而不是 返回>字节[]

关于时间:2019-03-17 标签:c#-System.FormatException: 'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52851292/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com