internal void event_CommitDataTableChanges(string tableName, DataTable dataTable) { try { event_OpenConnection(); string query = "SELECT * FROM [" + tableName + "]"; SQLiteDataAdapter dataAdapter; dataAdapter = new SQLiteDataAdapter(query, connection); SQLiteCommandBuilder commandBuilder; commandBuilder = new SQLiteCommandBuilder(dataAdapter); commandBuilder.QuotePrefix = "["; commandBuilder.QuoteSuffix = "]"; dataAdapter.DeleteCommand = commandBuilder.GetDeleteCommand(); dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand(); dataAdapter.InsertCommand = commandBuilder.GetInsertCommand(); dataAdapter.Update(dataTable); commandBuilder.Dispose(); dataAdapter.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LoadData() { SQLiteCommand command = _con.CreateCommand(); command.CommandText = "SELECT MAX(bizonylatszam) FROM befizetesek"; bizonylatszam = Convert.ToInt32(command.ExecuteScalar()); _adapTagok = new SQLiteDataAdapter("SELECT * FROM tagok", _con); _adapBefizetesek = new SQLiteDataAdapter("SELECT * FROM befizetesek", _con); SQLiteCommandBuilder _builderTagok = new SQLiteCommandBuilder(_adapTagok); _adapTagok.InsertCommand = _builderTagok.GetInsertCommand(); _adapTagok.DeleteCommand = _builderTagok.GetDeleteCommand(); _adapTagok.UpdateCommand = _builderTagok.GetUpdateCommand(); SQLiteCommandBuilder _builderBefizetesek = new SQLiteCommandBuilder(_adapBefizetesek); _adapBefizetesek.InsertCommand = _builderBefizetesek.GetInsertCommand(); _adapBefizetesek.DeleteCommand = _builderBefizetesek.GetDeleteCommand(); _adapBefizetesek.UpdateCommand = _builderBefizetesek.GetUpdateCommand(); _dataSet = new DataSet("befizetesek"); _adapTagok.Fill(_dataSet, "tagok"); _bindingSourceTagok.DataSource = _dataSet.Tables["tagok"]; _dataGridViewTagok.DataSource = _bindingSourceTagok; _adapBefizetesek.Fill(_dataSet, "befizetesek"); _bindingSourceBefizetesek.DataSource = _dataSet.Tables["befizetesek"]; _dataGridViewBefizetesek.DataSource = _bindingSourceBefizetesek; FormatTagokTable(); FormatBefizetesekTable(); }
public SQLiteDataAdapter GetDataAdapterSql(string sqlSelect, string sqlUpdate) { SQLiteCommand select = new SQLiteCommand(sqlSelect, cnSQL); SQLiteCommand selectUpdate = new SQLiteCommand(sqlUpdate, cnSQL); //выявляем параметры в запросе и создаем их в команде int p = 0; while (p < sqlSelect.Length) { p = sqlSelect.IndexOf('@', p); if (p < 0) { break; } int p2; for (p2 = ++p; p2 < sqlSelect.Length; p2++) //ищем конец имени поля { if (!char.IsLetterOrDigit(sqlSelect[p2])) { break; } } select.Parameters.Add(new SQLiteParameter(sqlSelect.Substring(p, p2 - p), null)); } SQLiteDataAdapter da = new SQLiteDataAdapter(selectUpdate); SQLiteCommandBuilder cb = new SQLiteCommandBuilder(da); cb.QuotePrefix = "["; cb.QuoteSuffix = "]"; da.UpdateCommand = cb.GetUpdateCommand(); da.InsertCommand = cb.GetInsertCommand(); da.DeleteCommand = cb.GetDeleteCommand(); da.SelectCommand = select; return(da); }
public void DeleteFlightPlan(string id) { SQLiteCommandBuilder builder = new SQLiteCommandBuilder(this.planDataAdapter); string expressionIdToFind = "Flight_id = '" + id + "'"; DataRow flightIdRow; try { flightIdRow = this.planDataTable.Select(expressionIdToFind).First(); } catch { throw new IDataBaseFlightPlan.ErrorIdNotExists(); } flightIdRow.Delete(); builder.GetInsertCommand(); this.planDataAdapter.Update(planDataTable); this.planDataTable.AcceptChanges(); SQLiteCommandBuilder builderSeg = new SQLiteCommandBuilder(this.segmantsDataAdapter); DataRow[] flightIdRowSeg = this.segmantsDataTable.Select(expressionIdToFind); int size = flightIdRowSeg.Length; for (int i = 0; i < size; i++) { flightIdRowSeg[i].Delete(); } builderSeg.GetInsertCommand(); this.segmantsDataAdapter.Update(segmantsDataTable); this.segmantsDataTable.AcceptChanges(); }
public static bool SaveTable(DataTable table) { Execute(string.Format("DELETE FROM {0}", table.TableName)); SQLiteConnection sQLiteConnection = new SQLiteConnection("Data Source=" + "C:\\Users\\chochheim\\Documents\\CSharpProjects\\StockcheckSQLiteDatabase\\bin\\Debug\\netcoreapp3.1\\database\\Deutschland.db"); sQLiteConnection.Open(); try { var cmd = sQLiteConnection.CreateCommand(); cmd.CommandText = string.Format("SELECT * FROM [{0}]", table.TableName); SQLiteDataAdapter _sQLiteAdapter = new SQLiteDataAdapter(cmd); SQLiteCommandBuilder builder = new SQLiteCommandBuilder(_sQLiteAdapter); builder.GetInsertCommand(); var ret = _sQLiteAdapter.Update(DatabaseTableFromConvenienceTable(table)); sQLiteConnection.Close(); return(true); } catch (System.Exception e) { Console.WriteLine(e.Message); sQLiteConnection.Close(); return(false); } }
/// <summary> /// Load data from database to datagrid /// </summary> private void LoadData() { try { sqlDataAdapter = new SQLiteDataAdapter("Select *, 'Delete' AS [Delete] FROM " + currentTable, SqlConnection); SqlCommandBuilder = new SQLiteCommandBuilder(sqlDataAdapter); SqlCommandBuilder.GetInsertCommand(); SqlCommandBuilder.GetUpdateCommand(); SqlCommandBuilder.GetDeleteCommand(); dataSet = new DataSet(); sqlDataAdapter.Fill(dataSet, currentTable); dataGridView1.DataSource = null; dataGridView1.DataSource = dataSet.Tables[currentTable]; for (int i = 0; i < dataGridView1.Rows.Count; i++) { DataGridViewLinkCell linkCell = new DataGridViewLinkCell(); dataGridView1[lastIndexTable, i] = linkCell; } dataGridView1.Refresh(); dataGridView1.Update(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void applyButton_Click(object sender, EventArgs e) { SQLiteConnection mCN = ConnectionManager.connection; SQLiteDataAdapter mDA = modulesTableAdapter.Adapter; SQLiteCommandBuilder mCB = new SQLiteCommandBuilder(mDA); DataSet mDS = modulesDataSet; DataSet dsChanges = new DataSet(); if (!mDS.HasChanges()) { return; } dsChanges = mDS.GetChanges(DataRowState.Modified); if (dsChanges != null) { mDA.UpdateCommand = mCB.GetUpdateCommand(); mDA.Update(dsChanges, "modules"); } dsChanges = mDS.GetChanges(DataRowState.Added); if (dsChanges != null) { mDA.InsertCommand = mCB.GetInsertCommand(); mDA.Update(dsChanges, "modules"); } dsChanges = mDS.GetChanges(DataRowState.Deleted); if (dsChanges != null) { mDA.DeleteCommand = mCB.GetDeleteCommand(); mDA.Update(dsChanges, "modules"); } mDS.AcceptChanges(); UpdateModulesDropDown(); (treeView.Model as SlowTreeModel).Root.UpdateModulesFromDbRec(); treeView.Invalidate(); }
public int?UpdateDt(DataTable Dt, string commandText) { //if application is exiting the don't perform DB process if (this.isAppClosing) { return(null); } if (!DoesDBConnectionExists()) { return(null); } try { SQLiteDataAdapter da = new SQLiteDataAdapter(commandText, _connection); SQLiteCommandBuilder cb = new SQLiteCommandBuilder(da); da.UpdateCommand = cb.GetUpdateCommand(); da.InsertCommand = cb.GetInsertCommand(); da.DeleteCommand = cb.GetDeleteCommand(); da.Update(Dt); } catch (Exception ex) { LogTrace.WriteErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, String.Format("Error in query . " + commandText + ex.StackTrace)); throw; } finally { commandText = string.Empty; } return(Dt.Rows.Count); }
public Query GetTableContent(Sql8rServer server, Sql8rDatabase database, Sql8rTable table, bool editable) { string sql = "SELECT * FROM {0};"; string dbSQL = string.Format(sql, table.Name); string dbConn = ConnectionString; using (var conn = new SQLiteConnection(dbConn)) { conn.Open(); var cmd = new SQLiteCommand(dbSQL, conn); var sdaDatabases = new SQLiteDataAdapter(cmd); if (editable) { var scb = new SQLiteCommandBuilder(sdaDatabases); sdaDatabases.UpdateCommand = scb.GetUpdateCommand(); sdaDatabases.InsertCommand = scb.GetInsertCommand(); sdaDatabases.DeleteCommand = scb.GetDeleteCommand(); } var dsDatabases = new DataTable("TableContent"); sdaDatabases.Fill(dsDatabases); var query = new Query(_settings, server.Name, database.Name, dbSQL, dsDatabases); query.Adapter = sdaDatabases; return(query); } }
/// <summary> /// 批量插入数据。 /// </summary> /// <param name="dataTable">数据表</param> /// <param name="tableName">要插入的数据表名称</param> /// <param name="connKey">连接配置名称</param> public override void BatchInsert(DataTable dataTable, string tableName, string connKey = null) { var sql = string.Empty; try { this.Open(connKey); this.Command.CommandType = CommandType.Text; this.Command.CommandText = "SELECT * FROM " + tableName; var dt = dataTable.Copy(); foreach (DataRow dr in dt.Rows) { if (dr.RowState == DataRowState.Unchanged) { dr.SetAdded(); } } this.Command.Transaction = this.Connection.BeginTransaction(); var da = new SQLiteDataAdapter((SQLiteCommand)this.Command); var cb = new SQLiteCommandBuilder(da); da.InsertCommand = cb.GetInsertCommand(); da.Update(dt); this.Command.Transaction.Commit(); } catch (Exception ex) { throw new DataObjectException("批量插入数据时出现错误:" + ex.Message + "\r\n" + sql, ex); } }
public int Insert <T>(DataTable dt) { int count = 0; SQLiteConnection conn = new SQLiteConnection(ConnectionStr); SQLiteCommand comm = new SQLiteCommand(" select * from " + typeof(T).Name + " limit 1 ", conn); try { conn.Open(); SQLiteTransaction ts = conn.BeginTransaction(); SQLiteDataAdapter dadpter = new SQLiteDataAdapter(comm); SQLiteCommandBuilder buider = new SQLiteCommandBuilder(dadpter); dadpter.InsertCommand = buider.GetInsertCommand(); count = dadpter.Update(dt); ts.Commit(); } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(count); }
public bool UploadImage_SQLite(string strFullPath, string strFileName) { try { string strCMD = "SELECT * FROM " + strTableName + " WHERE Name='1';"; using (SQLiteConnection connDEO = new SQLiteConnection(strSQLconn_SQLite)) { SQLiteCommand cmd = new SQLiteCommand(strCMD, connDEO); SQLiteDataAdapter sqlDA = new SQLiteDataAdapter(cmd); DataSet ds = new DataSet(); sqlDA.Fill(ds, "Images"); byte[] bImageData; if (!ReadFromDisc(strFullPath, out bImageData)) { return(false); } DataRow nr = ds.Tables["Images"].NewRow(); nr["Name"] = strFileName; nr["Data"] = bImageData; ds.Tables["Images"].Rows.Add(nr); SQLiteCommandBuilder sqlCmdBld = new SQLiteCommandBuilder(sqlDA); sqlDA.InsertCommand = sqlCmdBld.GetInsertCommand(); //sqlDA.UpdateCommand = sqlCmdBld.GetUpdateCommand(); //sqlDA.DeleteCommand = sqlCmdBld.GetDeleteCommand(); sqlDA.Update(ds, "Images"); } return(true); } catch { return(false); } }
/// <summary> /// 执行整表插入数据操作 /// </summary> /// <param name="tableName">需要操作的表名</param> /// <param name="dt">需要插入的表数据</param> /// <returns></returns> public int ExecuteInsertByDataTable(string tableName, DataTable dt) { int affectedRows = 0; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { try { connection.Open(); } catch { throw; } using (SQLiteTransaction tran = connection.BeginTransaction()) { try { string sql = "select * from " + tableName + " where 1=2"; SQLiteDataAdapter da = new SQLiteDataAdapter(sql, connection); SQLiteCommandBuilder scb = new SQLiteCommandBuilder(da); da.InsertCommand = scb.GetInsertCommand(); affectedRows = da.Update(dt); tran.Commit(); } catch (Exception) { tran.Rollback(); throw; } } } return(affectedRows); }
public int SaveDataTable(System.Data.DataTable dt) { SQLiteTransaction tran = null; try { SQLiteDataAdapter adapter = new SQLiteDataAdapter(); string sql = string.Format(@"select * from {0} where 1=2", dt.TableName); SQLiteCommand cmd = new SQLiteCommand(_Conn);; SQLiteCommandBuilder comBuilder = new SQLiteCommandBuilder(); comBuilder.DataAdapter = adapter; cmd.CommandText = sql; cmd.Connection = _Conn; adapter.SelectCommand = cmd; adapter.InsertCommand = comBuilder.GetInsertCommand(); adapter.UpdateCommand = comBuilder.GetUpdateCommand(); adapter.DeleteCommand = comBuilder.GetDeleteCommand(); tran = _Conn.BeginTransaction();//transaction begin 传说中sqlite每执行一条insert语句都开启一个事务,死慢 cmd.Transaction = tran; int result = adapter.Update(dt); tran.Commit();//transaction end return(result); } catch (Exception ex) { if (tran != null) { tran.Rollback(); } throw ex; } }
static void Main(string[] args) { // For this code to work you have to create a SQLite database and adjust the // table and column names below. SQLiteConnection conn = new SQLiteConnection(@"Data Source=D:\Projekte\NDO\SqliteProvider\NDOUnitTests.db"); SQLiteDataAdapter a = new SQLiteDataAdapter("Select * from Mitarbeiter", conn); SQLiteCommandBuilder cb = new SQLiteCommandBuilder(a); conn.Open(); /* * DataSet ds = new DataSet(); * ds.Tables.Add( "Test" ); * DataTable dt = ds.Tables["Test"]; * dt.Columns.Add( "intCol", typeof( int ) ); * dt.Columns.Add( "stringCol", typeof( string ) ); * dt.Columns.Add( "boolCol", typeof( bool ) ); * DataRow row = dt.NewRow(); */ SQLiteCommand cmd = cb.GetInsertCommand(); string s = cmd.CommandText; foreach (SQLiteParameter par in cmd.Parameters) { Console.WriteLine(" " + par.DbType + " " + par.Size); } //Clipboard.SetDataObject(s); Console.WriteLine(s); conn.Close(); Console.ReadLine(); }
private void CveDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { SQLiteCommandBuilder scb = new SQLiteCommandBuilder(mAdapter); mAdapter.InsertCommand = scb.GetInsertCommand(); mAdapter.Update(ds, t_name); CveDataGridView.ClearSelection(); }
static void Update(string tableName) { var adapter = Adapters[tableName]; var commandBuilder = new SQLiteCommandBuilder(adapter); adapter.DeleteCommand = commandBuilder.GetDeleteCommand(true); adapter.InsertCommand = commandBuilder.GetInsertCommand(true); adapter.UpdateCommand = commandBuilder.GetUpdateCommand(true); adapter.Update(Tables[tableName]); }
public void Push() { var builder = new SQLiteCommandBuilder(_adapter); _adapter.UpdateCommand = builder.GetUpdateCommand(); _adapter.InsertCommand = builder.GetInsertCommand(); _adapter.DeleteCommand = builder.GetDeleteCommand(); _adapter.Update(LocalDataTable); }
// Utilizes the SQLiteCommandBuilder, which in turn utilizes SQLiteDataReader's GetSchemaTable() functionality internal void InsertMany(DbConnection cnn, bool bWithIdentity) { int nmax = 1000; using (DbTransaction dbTrans = cnn.BeginTransaction()) { using (DbDataAdapter adp = new SQLiteDataAdapter()) { using (DbCommand cmd = cnn.CreateCommand()) { cmd.Transaction = dbTrans; cmd.CommandText = "SELECT * FROM TestCase WHERE 1=2"; adp.SelectCommand = cmd; using (DbCommandBuilder bld = new SQLiteCommandBuilder()) { bld.DataAdapter = adp; using (adp.InsertCommand = (SQLiteCommand)((ICloneable)bld.GetInsertCommand()).Clone()) { bld.DataAdapter = null; if (bWithIdentity) { adp.InsertCommand.CommandText += ";SELECT last_insert_rowid() AS [ID]"; adp.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord; } using (DataTable tbl = new DataTable()) { adp.Fill(tbl); for (int n = 0; n < nmax; n++) { DataRow row = tbl.NewRow(); row[1] = n + nmax; tbl.Rows.Add(row); } frm.Write(String.Format(" InsertMany{0} ({1} rows) Begins ... ", (bWithIdentity == true) ? "WithIdentityFetch" : " ", nmax)); int dtStart = Environment.TickCount; adp.Update(tbl); int dtEnd = Environment.TickCount; dtEnd -= dtStart; frm.Write(String.Format("Ends in {0} ms ... ", (dtEnd))); dtStart = Environment.TickCount; dbTrans.Commit(); dtEnd = Environment.TickCount; dtEnd -= dtStart; frm.WriteLine(String.Format("Commits in {0} ms", (dtEnd))); } } } } } } }
public override DbDataAdapter CreateAdapter(Table table, TableFilter filter) { if (!(table is SQLiteTable)) { throw new ArgumentException("Table must be of type SQLiteTable", "table"); } var adapter = new SQLiteDataAdapter(table.GetBaseSelectCommandText(filter), Connection); if (!table.IsReadOnly) { var builder = new SQLiteCommandBuilder(adapter) { ConflictOption = ConflictOption.OverwriteChanges }; SQLiteCommand updateCommand = null; try { updateCommand = builder.GetUpdateCommand(); } catch (InvalidOperationException) { var selectSql = new StringBuilder(); selectSql.Append("SELECT RowId, "); filter.WriteColumnsProjection(selectSql); selectSql.Append(" FROM "); selectSql.Append(table.QuotedName); adapter = new SQLiteDataAdapter(selectSql.ToString(), Connection); builder = new SQLiteCommandBuilder(adapter); updateCommand = builder.GetUpdateCommand(); } var insertCommand = builder.GetInsertCommand(); foreach (var column in table.Columns) { if (column.IsIdentity) { insertCommand.CommandText = insertCommand.CommandText + "; SELECT @RowId = last_insert_rowid()"; insertCommand.UpdatedRowSource = UpdateRowSource.OutputParameters; var parameter = new SQLiteParameter { ParameterName = "@RowId", Direction = ParameterDirection.Output, SourceColumn = column.Name, SourceVersion = DataRowVersion.Current, Value = DBNull.Value }; insertCommand.Parameters.Add(parameter); break; } } adapter.UpdateCommand = updateCommand; adapter.InsertCommand = insertCommand; adapter.DeleteCommand = builder.GetDeleteCommand(); } return(adapter); }
protected override DbDataAdapter GetDataAdapter(string tableName, string schemaName, bool forUpdating) { var adapter = new SQLiteDataAdapter(string.Format(CultureInfo.InvariantCulture, "SELECT * FROM \"{0}\"", tableName), _connection); if (forUpdating) { var builder = new SQLiteCommandBuilder(adapter); adapter.InsertCommand = builder.GetInsertCommand(); } return(adapter); }
public void writeDB() { using (var t = con.BeginTransaction()) { adp.InsertCommand = cb.GetInsertCommand(); adp.Update(cliente); t.Commit(); } }
public SQLiteDataAdapter GetSQLiteAdapter(string SelectCommand) { SQLiteDataAdapter adapter = new SQLiteDataAdapter(SelectCommand, this.connection); SQLiteCommandBuilder cb = new SQLiteCommandBuilder(adapter); adapter.InsertCommand = cb.GetInsertCommand(); adapter.UpdateCommand = cb.GetUpdateCommand(); adapter.DeleteCommand = cb.GetDeleteCommand(); return(adapter); }
// Summary: // Generates a command usable for replacing rows in a specified table private SQLiteCommand GetReplaceCommand(DataTable a_Template) { SQLiteDataAdapter adapter = new SQLiteDataAdapter("Select * from " + a_Template.TableName, m_DbConnection); SQLiteCommandBuilder cmdBuilder = new SQLiteCommandBuilder(adapter); SQLiteCommand replaceCommand = (SQLiteCommand)cmdBuilder.GetInsertCommand().Clone(); replaceCommand.CommandText = replaceCommand.CommandText.Replace("INSERT INTO", "REPLACE INTO"); // remove SQLiteCommandBuilder's side effects cmdBuilder.DataAdapter = null; return(replaceCommand); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { _ad = new SQLiteDataAdapter("select * from students", DB.Connection); var builder = new SQLiteCommandBuilder(_ad); _ad.DeleteCommand = builder.GetDeleteCommand(); _ad.InsertCommand = builder.GetInsertCommand(); _ad.UpdateCommand = builder.GetUpdateCommand(); _ad.Fill(_dt); btnEdit.Enabled = btnRemove.Enabled = _dt.Rows.Count != 0; listBox1.DataSource = _dt; listBox1.DisplayMember = "name"; }
/// <summary> /// 保存DataTable /// </summary> /// <param name="dt">DataTable</param> /// <returns>影响的行数</returns> public int SaveDataTable(SQLiteConnection conn, DataTable dt, string tableName) { bool isClose = conn == null; SQLiteTransaction _tran = null; try { if (isClose) { conn = this.GetSQLiteConnection(); conn.Open(); } else { if (conn.State == ConnectionState.Closed) { conn.Open(); } } SQLiteCommand command = conn.CreateCommand(); command.CommandText = "SELECT * FROM " + tableName; SQLiteDataAdapter oda = new SQLiteDataAdapter(command); SQLiteCommandBuilder ocb = new SQLiteCommandBuilder(oda); oda.InsertCommand = ocb.GetInsertCommand(); oda.UpdateCommand = ocb.GetUpdateCommand(); oda.DeleteCommand = ocb.GetDeleteCommand(); _tran = conn.BeginTransaction(); command.Transaction = _tran; int result = oda.Update(dt); _tran.Commit(); return(result); } catch (Exception ex) { _tran.Rollback(); throw new Exception(ex.Message); } finally { if (_tran != null) { _tran.Dispose(); } if (isClose) { conn.Close(); } } }
//adatok betöltése a fizikai adatbázisból a logikai adatbázisba private void LoadData() { _adap = new SQLiteDataAdapter("SELECT * FROM " + _tn, _con); SQLiteCommandBuilder builder = new SQLiteCommandBuilder(_adap); _adap.InsertCommand = builder.GetInsertCommand(); _adap.DeleteCommand = builder.GetDeleteCommand(); _adap.UpdateCommand = builder.GetUpdateCommand(); _dataSet = new DataSet(_tn); _adap.Fill(_dataSet, _tn); _bindingSource.DataSource = _dataSet.Tables[_tn]; FormatTables(_dataSet); }
public void Update(DataTable dataTable) { var query = $"select * from {TableName}"; using (SQLiteConnection connection = GetConnection()) using (var adapter = new SQLiteDataAdapter(query, connection)) using (var commandBuilder = new SQLiteCommandBuilder(adapter)) { adapter.UpdateCommand = commandBuilder.GetUpdateCommand(); adapter.DeleteCommand = commandBuilder.GetDeleteCommand(); adapter.InsertCommand = commandBuilder.GetInsertCommand(); adapter.Update(dataTable); } }
private void LoadData() { SQLiteCommand command = _con.CreateCommand(); command.CommandText = "SELECT MAX(kolcson_id) FROM kolcsonzesek"; kolcson_id = Convert.ToInt32(command.ExecuteScalar()); _adapKolcsonzesek = new SQLiteDataAdapter("SELECT * FROM kolcsonzesek WHERE vissza is null", _con); _adapTagok = new SQLiteDataAdapter("SELECT * FROM tagok", _con); _adapKonyvek = new SQLiteDataAdapter("SELECT * FROM konyvek", _con); SQLiteCommandBuilder _builderKolcsonzesek = new SQLiteCommandBuilder(_adapKolcsonzesek); _adapKolcsonzesek.InsertCommand = _builderKolcsonzesek.GetInsertCommand(); _adapKolcsonzesek.DeleteCommand = _builderKolcsonzesek.GetDeleteCommand(); _adapKolcsonzesek.UpdateCommand = _builderKolcsonzesek.GetUpdateCommand(); SQLiteCommandBuilder _builderTagok = new SQLiteCommandBuilder(_adapTagok); _adapTagok.InsertCommand = _builderTagok.GetInsertCommand(); _adapTagok.DeleteCommand = _builderTagok.GetDeleteCommand(); _adapTagok.UpdateCommand = _builderTagok.GetUpdateCommand(); SQLiteCommandBuilder _builderKonyvek = new SQLiteCommandBuilder(_adapKonyvek); _adapKonyvek.InsertCommand = _builderKonyvek.GetInsertCommand(); _adapKonyvek.DeleteCommand = _builderKonyvek.GetDeleteCommand(); _adapKonyvek.UpdateCommand = _builderKonyvek.GetUpdateCommand(); _dataSet = new DataSet("kolcsonzes"); _adapKolcsonzesek.Fill(_dataSet, "kolcsonzesek"); _bindingSourceKolcsonzesek.DataSource = _dataSet.Tables["kolcsonzesek"]; _dataGridViewKolcsonzesek.DataSource = _bindingSourceKolcsonzesek; _adapTagok.Fill(_dataSet, "tagok"); _bindingSourceTagok.DataSource = _dataSet.Tables["tagok"]; _dataGridViewTagok.DataSource = _bindingSourceTagok; _adapKonyvek.Fill(_dataSet, "konyvek"); _bindingSourceKonyvek.DataSource = _dataSet.Tables["konyvek"]; _dataGridViewKonyvek.DataSource = _bindingSourceKonyvek; FormatKolcsonzesekTable(); FormatTagokTable(); FormatKonyvekTable(); }
public void ShowWork() { tmp.dataGridView3.AllowUserToAddRows = false; tmp.dataGridView3.SelectionMode = DataGridViewSelectionMode.FullRowSelect; string sql_command = "select * from Worker"; adapter_worker = new SQLiteDataAdapter(sql_command, conn); CommandBuilder = new SQLiteCommandBuilder(adapter_worker); adapter_worker.UpdateCommand = CommandBuilder.GetUpdateCommand(); adapter_worker.InsertCommand = CommandBuilder.GetInsertCommand(); adapter_worker.DeleteCommand = CommandBuilder.GetDeleteCommand(); data_set_worker = new DataSet(); adapter_worker.Fill(data_set_worker); tmp.dataGridView3.DataSource = data_set_worker.Tables[0]; }