Answers for "C++ sqlite open file in other directory"

C++
1

C++ sqlite open file in other directory

int main(){
  
  sqlite3* db; // Pointer to SQLite connection
  const char* sqlFilename = "C:/Users/database.sqlite";//the path to your sqlite
  int error = sqlite3_open(sqlFilename, &db); //opening conection
  if(error){
      //if error then display error and close conection
      std::cout << "DB Open Error: " << sqlite3_errmsg(db) << std::endl;
      sqlite3_close(db);
      return 1;
  }
  else {
      std::cout << "Opened Database Successfully!" << std::endl;
  }
  return 0;
}
Posted by: Guest on August-02-2021

Browse Popular Code Answers by Language