Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Error SQLCE database



  • Hi everyone,

    I have a problem when I want to connect to my sdf database
    This is my code
    6e90115e-fe91-44e4-8c2d-7dad3460cd62-image.png

    I try with

    db.setDatabaseName("Data Source=F:\data.sdf;Persist Security Info=False;")

    But with this two case I have the same error :
    QSqlError("0", "QODBC: Unable to connect", "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified")

    Do you have an idea?
    Thank in advance



  • @AnthonyQt said in Error SQLCE database:

    db.setDatabaseName("Data Source=F:\data.sdf;Persist Security Info=False;")

    Just to be sure, like your original code you do use \\ here in your code, don't you?

    db.setDatabaseName("Data Source=F:\\data.sdf;Persist Security Info=False;")
    


  • @JonB said in Error SQLCE database:

    s

    I have the same error :/

    db.setDatabaseName("Data Source=F:\\data.sdf;Persist Security Info=False;")

    Give my QSqlError("0", "QODBC: Unable to connect", "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified")


  • Lifetime Qt Champion

    @AnthonyQt @JonB already told you that you should use \\ instead of \ , so please change the path accordingly...
    \ is escape character in C/C++.



  • @AnthonyQt
    You can see your pasted code still shows

    "Data Source=F:\data.sdf;Persist Security Info=False;"
    

    Meanwhile your original screenshot showed you using "F:\\data.sdf".

    Please learn to use the forum's Code tags to show your code correctly, then we would know.

    Is it too hard to answer my question about whether you have \ or \\ in your string?

    UPDATE I believe you have now edited your earlier post to change. Use Code tags! Who knows....



  • @JonB

    I have \\

    56dc104c-3268-42ef-b6b1-8e67d7566fc8-image.png

    But same error



  • @AnthonyQt
    Then if it works without Persist Security Info=False; (please verify), I can only assume that SQLCE ODBC driver does not like that parameter.....



  • c3d67e20-46f2-4ec6-b525-3880bb2cff59-image.png
    724a81e5-447d-413d-a344-ac047f1babb8-image.png

    I made this but I have the same error
    QSqlError("0", "QODBC: Unable to connect", "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified")

    02bc3100-29bc-4840-8a33-9db382857f7f-image.png
    But this give my true



  • @AnthonyQt
    But your very original post seemed to me at least to be saying you had it working with "F:\\data.sdf" but not with "Data Source=F:\\data.sdf;Persist Security Info=False;". Now it sounds like your issue has nothing to do with Persist Security Info=False;. I wish you would be clearer....

    Anyway, I can only guess that Data source name not found error message means either the syntax is wrong or F:\data.sdf does not exist/is not accessible.



  • @JonB said in Error SQLCE database:

    But your very original post seemed to me at least to be saying you had it working with "F:\data.sdf" but not with "Data Source=F:\data.sdf;Persist Security Info=False;". Now it sounds like your issue has nothing to do with Persist Security Info=False;. I wish you would be clearer....

    No It never worked
    I do this and move the database to D to see if the problem come from accessibility problem
    10910266-e6f9-4eaf-b3a8-160bb23c203c-image.png
    And I have this
    4f177d2f-5bba-44d5-81ed-f4cf50793ea6-image.png
    I don´t understand what is my error


Log in to reply