Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

关于“SqliteException:SQLiteerrornosuchcolumn:”错误 sql SQLServer sql数据库 数据 ...

$
0
0

关于“SqliteException:SQLiteerrornosuchcolumn:”错误,最近学Unity,用到SQLite作为数据库,使用的脚本都是@秦元培和@雨松MOMO的脚本,但在进行插入运算时出现了一个error, 即“SqliteException: SQLite error no such column:”。

弄了好久,发现是 变量string缺少 '',有时候向数据库中插入一些值,一定要注意对text类型的字段的插入,如果使用的是这样的sql : insert into 表名 values(id,name),记得name在插入时,使用'name',要加上' ' 否则就会出现no such column xxx错误。所以代码如下(注意加粗的代码):

public void OnClick()
{
HomeTeamName = "'"+gobj.GetComponent().captionText.text+"'";
AwayTeamName = gobj2.GetComponent().captionText.text;
sql.InsertValues("table1", new string[] { "'HomeTeam'", HomeTeamName });
}

Viewing all articles
Browse latest Browse all 3160

Trending Articles