2

Hi I've got this code which uses Access to open/store data in database. I need to convert this to use SQLite. However I'm finding it difficult to find the appropriate connection string. How should I go about doing this? Thanks

var dbaseConnection = Server.CreateObject("ADODB.Connection");          
var pathToDbase = Server.MapPath("contacts.mdb");            
var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + pathToDbase;
dbaseConnection.Open(connectionString);  

This is just test code but I am trying to just read and display information from an sqlite database.

    <table>
        <tr><th>Name</th><th>Surname</th></tr>

        <%

              var dbaseConnection = Server.CreateObject("ADODB.Connection");


              var connectionString = "DRIVER=SQLite3 ODBC Driver; Database= path to test.db; LongNames=0; Timeout=1000; NoTXN=0; SyncPragma=NORMAL; StepAPI=0;";
              dbaseConnection.Open(connectionString);

              var query = "Select * from test order by name asc";
              var recordSet = dbaseConnection.Execute(query);


              while (!recordSet.Eof) {
                 Response.write("<tr><td>" + recordSet("name") + '</td><td>' + recordSet("surname") + "</td></tr>");
                 recordSet.moveNext();
              }

              recordSet.Close();
              dbaseConnection.Close();

        %>

    </table>
</body>

I am now getting this error Microsoft OLE DB Provider for ODBC Drivers error '80004005' connect failed. Any thoughts? I've activated 32 bit apps in IIS.

0

1 Answer 1

1

DRIVER=SQLite3 ODBC Driver;Database=c:\mydb.db;LongNames=0;Timeout=1000;NoTXN=0; SyncPragma=NORMAL;StepAPI=0;

Reference: https://www.connectionstrings.com/sqlite/

Sign up to request clarification or add additional context in comments.

1 Comment

That's only half the story though. The driver doesn't ship with Windows, you need to install it yourself. web.synametrics.com/SQLite.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.