【问题标题】:Flutter SQLite Datatype mismatch on INSERT with the correct datatypes在 INSERT 上使用正确的数据类型 Flutter SQLite 数据类型不匹配
【发布时间】:2021-10-31 13:35:48
【问题描述】:

无论我如何尝试,我都会不断收到此错误

E/SQLiteLog( 9445): (20) statement aborts at 5: [INSERT Into Profile (mac,image,name,age,nationality,profession,about) VALUES ('0.0.0.0.0.0','/data/user/0/com.shades.flidar/cache/scaled_image_picker5826102720138113893.jpg','test','35',
E/SQLiteQuery( 9445): exception: datatype mismatch (code 20 SQLITE_MISMATCH); query: INSERT Into Profile (mac,image,name,age,nationality,profession,about) VALUES ('0.0.0.0.0.0','/data/user/0/com.test.test/cache/scaled_image_picker5826102720138113893.jpg','test','35','test','test','test');
E/flutter ( 9445): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: DatabaseException(datatype mismatch (code 20 SQLITE_MISMATCH)) sql 'INSERT Into Profile (mac,image,name,age,nationality,profession,about) VALUES ('0.0.0.0.0.0','/data/user/0/com.test.test/cache/scaled_image_picker5826102720138113893.jpg','test','35','test','test','test');' args []

这是代码:

customQuery("CREATE TABLE Profile ("
"mac TEXT,"
"image TEXT,"
"name TEXT,"
"age TEXT,"
"nationality TEXT,"
"profession TEXT,"
"about TEXT"
")");

onPressed: () {
    profile.add(Profile(
        mac: _platformVersion,
        image: imagePath,
        name: nameController.text,
        age: ageController.text,
        nationality: nationalityController.text,
        profession: professionController.text,
        about: aboutController.text));

    DBProvider.db.customQuery("INSERT Into Profile (mac,image,name,age,nationality,profession,about)"
        " VALUES ('${profile[0].mac}','${profile[0].image}',"
        "'${profile[0].name}','${profile[0].age}','${profile[0].nationality}',"
        "'${profile[0].profession}','${profile[0].about}');");
       },

我真的不知道为什么,请帮忙! 谢谢!

【问题讨论】:

    标签: android ios database flutter sqlite


    【解决方案1】:

    profile[0].age 应该返回一个字符串数据类型。

    【讨论】:

    • 谢谢,它确实返回一个字符串值
    猜你喜欢
    • 2016-11-07
    • 1970-01-01
    • 2020-08-28
    • 2023-01-31
    • 1970-01-01
    • 2021-08-18
    • 2013-07-07
    • 1970-01-01
    • 2016-08-20
    相关资源
    最近更新 更多