Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
}
 
PREVIOUS NEXT
Tagged: #sqlite #open #file #directory
ADD COMMENT
Topic
Name
8+4 =