Mono SQLite:System.InvalidCastException:指定的强制转换无效

我正在尝试以动态方式在统一项目中插入以下命令:

 public static string insertPlayerCmd = "INSERT INTO Player (Name) VALUES (?);";

我在存储库上使用此方法将名称插入数据库:

  public accountContents Saveaccount(string newName)
    {
        string name = newName;
        var transaction = Finder.DB.DatabaseConnection.BeginTransaction();
        var command = Finder.DB.DatabaseConnection.CreateCommand();
        accountContents newaccountContents = null;

        try
        { 
            command.CommandText = ConstantDbRequests.insertPlayerCmd;
            command.Parameters.Add(newName);
            var newaccount = command.ExecuteReader(); 
            transaction.Commit();
            newaccountContents = new accountContents(newaccount.GetInt32(0),newaccount.GetString(1));
        } 
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }

        return newaccountContents;
    }

command.Parameters.Add(newName);行引发了无效的强制转换异常。

我在SQLite中验证了我的数据库,并且要插入的列为Text类型,SQL命令上的所有名称均正确写入,但是我无法添加参数来替换?。通配符

dengluxinqing 回答:Mono SQLite:System.InvalidCastException:指定的强制转换无效

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3122881.html

大家都在问