C#SQLite连接器问题

C#SQLite连接器问题,c#,.net,sqlite,C#,.net,Sqlite,鉴于代码: SQLiteCommand cmd = new SQLiteCommand("UPDATE \"Category\" SET \"name\"=?name, \"description\"=?description, \"color\"=?color, \"active\"=?active, \"parent\"=?parent WHERE \"id\"=?id", sql); cmd.Parameters.Add("?id", DbType.In

鉴于代码:

        SQLiteCommand cmd = new SQLiteCommand("UPDATE \"Category\" SET \"name\"=?name, \"description\"=?description, \"color\"=?color, \"active\"=?active, \"parent\"=?parent WHERE \"id\"=?id", sql);  
        cmd.Parameters.Add("?id", DbType.Int32).Value = _id;  
        cmd.Parameters.Add("?name", DbType.String).Value = _name;  
        cmd.Parameters.Add("?description", DbType.String).Value = _description;  
        cmd.Parameters.Add("?color", DbType.Int32).Value = _color;  
        cmd.Parameters.Add("?active", DbType.Boolean).Value = _active;  
        cmd.Parameters.Add("?parent", DbType.Int32).Value = _parent;  
        cmd.Prepare();  
        cmd.ExecuteNonQuery();  
我们遇到了最后一行抛出的问题

SQLite error  near "name": syntax error  
这是胡说八道。一定还有别的事。桌子是连接和打开的(我可以从桌子上很好地看到),其他一切都很好。由于某种原因,它似乎无法处理这个简单的更新


编辑:好的。我试着把名字字段完全去掉,但还是没有骰子。我只是得到了描述字段上的错误。这绝对不是关键词问题。

您尝试过以下方法吗

cmd.Parameters.Add("@id", DbType.Int32);  
cmd.Parameters.Add("@name", DbType.String);  
...

cmd.Parameters["@id"].Value = _id;  
cmd.Parameters["@name"].Value = _name;  
... 

在sql语法中,在字段名周围使用括号,因为它们也可能与保留字冲突。括号将消除此问题。我不确定,但id和name都可以是保留字。

您是否尝试过将命名参数从name更改为其他名称?这可能是关键字问题吗?@Kevin Hsu我尝试将其重命名为zname,但仍然出现相同的错误。是否需要为字符串提供Size属性?你在使用谁的提供商?@Tim我用size属性试过了,还是一样的问题。提供程序是System.Data.SQLite from。即使没有名称字段,它也只是说它与description then.Bam有问题?参数是MySQL连接器喜欢的方式。SQLite连接器使用@而不是?来处理@参数?。