值将被赋予mysql命令中的参数,但它不会返回正确的id

时间:2017-01-30 09:18:24

标签: c# mysql

以下是程序中执行查询的示例:

        Int64 kooid = new Int64();
        myCommand.CommandText = ("SELECT kooiid FROM kooien where NummerExtern =?NummerExtern");
        myCommand.Parameters.Add("?NummerExtern", MySqlDbType.Int64).Value = kooi.Kooinr;
        kooid = Convert.ToInt64(myCommand.ExecuteScalar());
        return kooid;

这是表化妆的一个例子

kooiid(int)| kooidlistppg(int)|quarantaine(tiny int) |idvogelsoort(int)|idvogelondersoort(int)| vasteoflossekooie(tiny int)| bezetofniet(tiny int)| idsponsor(int)| NummerExtern(int)

在你问我什么时候运行查询manualy它的功能,但是当程序很好地排序时,即使kooinr变量是正确的,查询返回零到kooiid

1 个答案:

答案 0 :(得分:0)

找到解决方案

Int64 kooid = new Int64();
        myCommand.CommandText = ("Select kooiid from kooien where NummerExtern = ?NummerExtern");
        myCommand.Parameters.Add("?NummerExtern", MySqlDbType.Int64).Value = kooi.Kooinr;
        string kooidstring = myCommand.ExecuteScalar().ToString();
        kooid = Convert.ToInt64(kooidstring);
        return kooid;