private void sqlLiteToolStripMenuItem_Click(object sender, EventArgs e) { //on load for selecting sqlite currentDatabaseType = DatabaseType.Sqlite; //if (_filepath == string.Empty) //{ _filepath = chooseFile(); //} SqLiteDb sqLiteDbConn = new SqLiteDb(_filepath); try { //sqLiteDbConn.connectionString = filepath; bool pass = sqLiteDbConn.openDb(); //lbl_Error.Text = string.Format("*** Connection *** {0}", pass); lbl_databaseName.Text = string.Format("Connected to {0} - {1}", sqLiteDbConn.dbName, "SQLite Database"); List <string> tableData = sqLiteDbConn.getTableNames(); cmb_tableName.DataSource = tableData; } catch (Exception ex) { throw new Exception(ex.Message); } sqLiteDbConn.closeDB(); }
private void btn_Run_Click(object sender, EventArgs e) { string dbCommand = txt_schema.Text; if (currentDatabaseType == DatabaseType.Sqlite) { if (_filepath == string.Empty) { _filepath = chooseFile(); } SqLiteDb sqLiteDbConn = new SqLiteDb(_filepath); sqLiteDbConn.openDb(); var reader = sqLiteDbConn.executeCommand(dbCommand); fillGridView(reader); sqLiteDbConn.closeDB(); } else if (currentDatabaseType == DatabaseType.SQL) { Sql connection = new Sql(@"localhost", "tempdb", "sa", "123"); connection.openDb(); var reader = connection.executeCommand(dbCommand); fillGridView(reader); connection.closeDB(); } }
private void fillTableWithData(string tableName) { string selectProcedure = string.Format("select * from {0};", tableName); if (currentDatabaseType == DatabaseType.Sqlite) { if (_filepath == string.Empty) { _filepath = chooseFile(); } SqLiteDb sqLiteDbConn = new SqLiteDb(_filepath); sqLiteDbConn.openDb(); var reader = sqLiteDbConn.executeCommand(selectProcedure); fillGridView(reader); sqLiteDbConn.closeDB(); } else if (currentDatabaseType == DatabaseType.SQL) { Sql sqlDbConn = new Sql(@"localhost", "tempdb", "sa", "123"); sqlDbConn.openDb(); var reader = sqlDbConn.executeCommand(selectProcedure); fillGridView(reader); sqlDbConn.closeDB(); } }
private void sqliteToolStripMenuItem_Click(object sender, EventArgs e) { currentDatabaseType = DatabaseType.Sqlite; FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { _filepath = folderBrowserDialog.SelectedPath; } SqLiteDb sq = new SqLiteDb(_filepath + "\\test.db"); sq.createDb(_filepath + "\\test.db"); sq.openDb(); Console.WriteLine(sq.connectionString); Console.WriteLine(sq.isConnectionOpen); sq.closeDB(); }
private void btn_getSchema_Click(object sender, EventArgs e) { if (DatabaseType.Sqlite == currentDatabaseType) { if (_filepath == string.Empty) { _filepath = chooseFile(); } SqLiteDb sqLiteDbConn = new SqLiteDb(_filepath); sqLiteDbConn.openDb(); var tableData = sqLiteDbConn.getTableData(); sqLiteDbConn.closeDB(); } else if (DatabaseType.SQL == currentDatabaseType) { Sql sqlDbConn = new Sql(@"localhost", "tempdb", "sa", "123"); sqlDbConn.openDb(); var tableData = sqlDbConn.getTableData(); sqlDbConn.closeDB(); } }