private void Window_Loaded(object sender, RoutedEventArgs e) { try { idx = null; SqlCeDataReader myReader = null; SqlCeCommand command = new SqlCeCommand("select DRV_NAME from Driver", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { comboBox1.Items.Add(myReader["DRV_NAME"].ToString()); } myReader.Close(); myReader.Dispose(); command = new SqlCeCommand("select CMP_NAME from Company", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { comboBox2.Items.Add(myReader["CMP_NAME"].ToString()); } myReader.Close(); myReader.Dispose(); command = new SqlCeCommand("select SERV_NAME from Service_Type", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { comboBox3.Items.Add(myReader["SERV_NAME"].ToString()); } myReader.Close(); myReader.Dispose(); command = new SqlCeCommand("select DOC_TYPE_NAME from Document_Type", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { comboBox4.Items.Add(myReader["DOC_TYPE_NAME"].ToString()); } myReader.Close(); myReader.Dispose(); listView1.ItemsSource = transactions; } catch (System.Exception ex) { log.Error(ex); Config.FatalError(); } }
public void Load() { var command = DataStore.Connection.CreateCommand(); SqlCeDataReader reader = null; command.CommandText = "SELECT * FROM [reminders] ORDER BY [time]"; reader = command.ExecuteReader(); while (reader.Read()) { Reminder rem = new Reminder(this); rem.Name = reader.GetString("name"); rem.Text = reader.GetString("text"); rem.Time = reader.GetDateTime("time"); rem.Frequency = reader.GetEnum <Frequency>("frequency"); reminders.Add(rem); rem.Init(); } reader.Dispose(); command.Dispose(); }
private void DeleteCatButton_Click(object sender, EventArgs e) { int docCount = 0; openAppDocDatabase(); SqlCeCommand cmd = TecanAppDocDatabase.CreateCommand(); cmd.CommandText = "SELECT DocID FROM Documents WHERE ApplicationCategory = " + Convert.ToInt32(CurrentCatID.Text); SqlCeDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { docCount++; } reader.Dispose(); if (docCount > 0) { MessageBox.Show("There are documents in application category " + AddEditCategoryTextBox.Text + ".\n\nPlease change the document categories before deleting this category."); } else { cmd.CommandText = "DELETE FROM ApplicationCategories WHERE AppCategoryID = " + Convert.ToInt32(CurrentCatID.Text); cmd.ExecuteNonQuery(); int whichSelected; if (CategoryListView.SelectedIndices.Count > 0) { whichSelected = CategoryListView.SelectedIndices[0]; CategoryListView.Items.RemoveAt(whichSelected); } } TecanAppDocDatabase.Close(); CatPanel.Visible = false; }
private void PopulateListBox() { try { cn.Open(); } catch (SqlCeException ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } SqlCeCommand cm = new SqlCeCommand("SELECT ([Make] + ' - ' + [Model] + ' - ' + [Price] + ' - ' + [Stock]) AS Info FROM tblVehicleStock WHERE Make = '" + this.txtMake.Text + "' OR Model = '" + this.txtModel.Text + "' ORDER BY Make", cn); try { SqlCeDataReader dr = cm.ExecuteReader(); while (dr.Read()) { this.listVehicles.Items.Add(dr["Info"]); } dr.Close(); dr.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void loadRequiredParts(String SAPID) { RequiredListView.Items.Clear(); openDB(); SqlCeCommand cmd = TecanDatabase.CreateCommand(); cmd.CommandText = "SELECT R.RequiredSAPId, P.Description FROM RequiredParts R" + " INNER JOIN PartsList P " + " ON R.RequiredSAPId = P.SAPId" + " WHERE R.SAPId = '" + SAPID + "'" + " ORDER BY RequiredSAPId"; try { SqlCeDataReader reader = cmd.ExecuteReader(); int partCount = 0; while (reader.Read()) { RequiredListView.Items.Add(reader[0].ToString()); RequiredListView.Items[partCount].SubItems.Add(reader[1].ToString()); partCount++; } reader.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } TecanDatabase.Close(); }
public void Load() { var command = DataStore.Connection.CreateCommand(); SqlCeDataReader reader = null; command.CommandText = "SELECT [text] FROM [pad] ORDER BY [id]"; Lines.Clear(); reader = command.ExecuteReader(); while (reader.Read()) { Lines.Add(new Line { Text = reader.GetString(0) }); } if (Lines.Count == 0 || Lines.Last().Text != "") { Lines.Add(new Line { Text = "" }); } reader.Dispose(); command.Dispose(); }
public bool IsDatabaseEmpty() { bool databaseIsEmpty = true; SqlCeDataReader reader = null; try { reader = DA.GetData("SELECT * FROM EmailSettings"); if (reader.Read()) { databaseIsEmpty = false; } } catch (Exception ex) { throw new Exception("Error in checking if database is empty. " + ex.Message); } finally { reader.Dispose(); } return(databaseIsEmpty); }
private void PopulateComboBox() { try { cn.Open(); } catch (SqlCeException ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } SqlCeCommand cm = new SqlCeCommand("SELECT ([FirstName] + ' ' + [LastName]) AS FullName FROM tblCustomer ORDER BY [FirstName]", cn); try { SqlCeDataReader dr = cm.ExecuteReader(); while (dr.Read()) { this.cmbCustomer.Items.Add(dr["FullName"]); } dr.Close(); dr.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { PeriodSelected = false; SqlCeDataReader myReader = null; SqlCeCommand command = new SqlCeCommand("select CMP_COD, CMP_NAME from Company", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { int Code = Convert.ToInt32(myReader["CMP_COD"].ToString()); string name = myReader["CMP_NAME"].ToString(); if (!companies.Contains(name)) { companies.Add(name); } if (!dct_companies.ContainsKey(name)) { dct_companies.Add(name, Code); } } myReader.Close(); myReader.Dispose(); comboBox1.ItemsSource = companies; } catch (Exception ex) { log.Error(ex); } }
private void AddCompany_Click(object sender, RoutedEventArgs e) { AddNewCompany dlg = new AddNewCompany(); dlg.conn = conn; dlg.mode = Mode.MODE_CREATE; dlg.ShowDialog(); try { SqlCeDataReader myReader = null; SqlCeCommand command = new SqlCeCommand("select CMP_COD, CMP_NAME from Company", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { int Code = Convert.ToInt32(myReader["CMP_COD"].ToString()); string name = myReader["CMP_NAME"].ToString(); if (!companies.Contains(name)) { companies.Add(name); } if (!dct_companies.ContainsKey(name)) { dct_companies.Add(name, Code); } } myReader.Close(); myReader.Dispose(); comboBox2.ItemsSource = companies; } catch (System.Exception ex) { log.Error(ex); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { button3.IsEnabled = false; idx = null; SqlCeDataReader myReader = null; SqlCeCommand command = new SqlCeCommand("select TaxName, TaxAmount, TaxDescription from AppliedTaxes", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { AppliedTax t = new AppliedTax(); t.TaxAmount = Convert.ToDecimal(myReader["TaxAmount"].ToString()); t.TaxDescription = myReader["TaxDescription"].ToString(); t.TaxName = myReader["TaxName"].ToString(); taxes.Add(t); } myReader.Close(); myReader.Dispose(); listView1.ItemsSource = taxes; } catch (System.Exception ex) { log.Error(ex); } }
private int getLastDocId() { int docCount = 0; openAppDocDatabase(); SqlCeCommand cmd = TecanAppDocDatabase.CreateCommand(); cmd.CommandText = "SELECT DocID FROM Documents ORDER BY DocID"; try { SqlCeDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { docCount = Convert.ToInt32(reader[0].ToString()); } reader.Dispose(); } catch (Exception ex) { MessageBox.Show("Unable to get Last Doc ID: " + ex.Message); } docCount++; return(docCount); }
private void LoadCatList() { openAppDocDatabase(); SqlCeCommand cmd = TecanAppDocDatabase.CreateCommand(); cmd.CommandText = "SELECT AppCategoryID, AppCategoryName FROM ApplicationCategories"; try { SqlCeDataReader reader = cmd.ExecuteReader(); int catCount = 0; while (reader.Read()) { CategoryListView.Items.Add(""); CategoryListView.Items[catCount].SubItems.Add(reader[0].ToString()); CategoryListView.Items[catCount].SubItems.Add(reader[1].ToString()); catCount++; } reader.Dispose(); } catch (Exception ex) { MessageBox.Show("Loading Categories List: " + ex.Message); } TecanAppDocDatabase.Close(); }
private void ViewDocumentButton_Click(object sender, EventArgs e) { Int32 EditDocID = Convert.ToInt32(AppDocIDTextBox.Text); String Filename = AppDocFilenameTextBox.Text; openAppDocDatabase(); SqlCeCommand cmd = TecanAppDocDatabase.CreateCommand(); cmd.CommandText = "SELECT Document FROM Documents WHERE DocID = '" + EditDocID + "'"; SqlCeDataReader reader = cmd.ExecuteReader(); reader = cmd.ExecuteReader(); Byte[] documentData = new Byte[0]; while (reader.Read()) { documentData = (byte[])reader[0]; } reader.Dispose(); TecanAppDocDatabase.Close(); // Create the new file in temp directory String tempFilePath = @AppDomain.CurrentDomain.BaseDirectory.ToString() + "temp"; System.IO.Directory.CreateDirectory(tempFilePath); // If temp directory current contains any files, delete them System.IO.DirectoryInfo tempFiles = new DirectoryInfo(tempFilePath); foreach (FileInfo file in tempFiles.GetFiles()) { file.Delete(); } String fullFilePathName = @tempFilePath + "\\" + Filename; System.IO.FileStream fs = System.IO.File.Create(fullFilePathName); fs.Close(); // Write file contents into file BinaryWriter Writer = null; try { // Create a new stream to write to the file Writer = new BinaryWriter(File.OpenWrite(fullFilePathName)); // Writer raw data Writer.Write(documentData); Writer.Flush(); Writer.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } Process.Start(fullFilePathName); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { /* load lookup info */ idx = null; SqlCeDataReader myReader = null; SqlCeCommand command = new SqlCeCommand("select VIL_NAME from Village", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { comboBox1.Items.Add(myReader["VIL_NAME"].ToString()); } myReader.Close(); myReader.Dispose(); command = new SqlCeCommand("select PAR_NAME from Parish", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { comboBox2.Items.Add(myReader["PAR_NAME"].ToString()); } myReader.Close(); myReader.Dispose(); command = new SqlCeCommand("select COU_NAME from Country", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { comboBox3.Items.Add(myReader["COU_NAME"].ToString()); } myReader.Close(); myReader.Dispose(); listView1.ItemsSource = drivers; } catch (System.Exception ex) { log.Error(ex); Config.FatalError(); } }
private void ReadNextItem() { try { if (conn == null) { conn = new SqlCeConnection(connString); conn.Open(); } SqlCeCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM banklogs WHERE cat IS NULL AND idx>@index;"; cmd.Parameters.AddWithValue("@index", current_reader != null ? (int)current_reader[0] : 0); SqlCeDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { current_reader = reader; dateTimePicker1.Value = (DateTime)current_reader[1]; textBox2.Text = current_reader[2].ToString(); textBox3.Text = current_reader[3].ToString(); textBox4.Text = current_reader[6].ToString(); textBox5.Text = current_reader[4].ToString(); textBox6.Text = current_reader[5].ToString(); textBox7.Text = current_reader[7].ToString(); } else { current_reader = null; dateTimePicker1.ResetText(); textBox2.ResetText(); textBox3.ResetText(); textBox4.ResetText(); textBox5.ResetText(); textBox6.ResetText(); textBox7.ResetText(); } } catch (Exception E) { MessageBox.Show(E.Message); if (current_reader != null) { current_reader.Dispose(); current_reader = null; } conn.Close(); conn = null; } }
public void GetAllClientData() { SqlCeCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM Users"; SqlCeDataReader reader = command.ExecuteReader(); while (reader.Read()) { string txt = "[ " + reader[0].ToString() + " ] [ " + (string)reader[1] + " ] [ " + (string)reader[2] + " ] [ " + reader[3].ToString() + " ] [ " + reader[4].ToString() + " ]"; lb.Invoke(new Action(() => lb.Items.Add(txt))); } reader.Dispose(); }
public static Image GetImagem(Int64 Id, string tabela, string campoId) { //string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.dbintegracaoConnectionString"].ConnectionString; string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.ConnectionString"].ConnectionString; Byte[] ImageByte; Image retorno = null; //MySqlConnection con = new MySqlConnection(ConnectionString); SqlCeConnection con = new SqlCeConnection(ConnectionString); try { con.Open(); string sql = string.Empty; if (!string.IsNullOrEmpty(tabela) & !string.IsNullOrEmpty(campoId)) { sql = "SELECT imagem from " + tabela + " where " + campoId + " = @Id"; //MySqlCommand cmd = new MySqlCommand(sql, con); SqlCeCommand cmd = new SqlCeCommand(sql, con); cmd.Parameters.AddWithValue("@Id", Id); //MySqlDataReader dr = cmd.ExecuteReader(); SqlCeDataReader dr = cmd.ExecuteReader(); bool HasRows = dr.Read(); if (HasRows) { ImageByte = (Byte[])dr["imagem"]; if (ImageByte != null) { retorno = ByteToImage(ImageByte); } } dr.Close(); dr.Dispose(); cmd.Dispose(); } return(retorno); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } }
/// <summary> /// Retorna o próximo número da sequência informada no parametro. /// </summary> /// <param name="Sequence"></param> /// <returns></returns> public static long GetNextVal(string Sequence) { //string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.dbintegracaoConnectionString"].ConnectionString; string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.ConnectionString"].ConnectionString; //"server=localhost;user id=root;Password=pass4admin;database=dbintegracao"; long retorno = 0; SqlCeConnection con = new SqlCeConnection(ConnectionString); //MySqlConnection con = new MySqlConnection(ConnectionString); try { con.Open(); SqlCeCommand cmd = new SqlCeCommand("SELECT sequence_increment, sequence_cur_value FROM sequence_data WHERE sequence_name = '" + Sequence + "'", con); //MySqlCommand cmd = new MySqlCommand("SELECT nextval('" + Sequence + "') as nextsequence", con); //MySqlDataReader dr = cmd.ExecuteReader(); SqlCeDataReader dr = cmd.ExecuteReader(); bool HasRows = dr.Read(); if (HasRows) { int increment = Convert.ToInt32(dr[0]); long cur_value = Convert.ToInt64(dr[1]); cur_value += increment; retorno = cur_value; SqlCeCommand UPD = new SqlCeCommand("UPDATE sequence_data SET sequence_cur_value = " + cur_value.ToString() + " WHERE sequence_name = '" + Sequence + "'", con); UPD.ExecuteNonQuery(); UPD.Dispose(); } dr.Close(); dr.Dispose(); cmd.Dispose(); return(retorno); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } }
private void SuppDocForm_Load(object sender, EventArgs e) { SqlCeConnection TecanSuppDocsDatabase = null; TecanSuppDocsDatabase = new SqlCeConnection(); String dataPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); TecanSuppDocsDatabase.ConnectionString = "Data Source=|DataDirectory|\\TecanSuppDocs.sdf;Max Database Size=4000;Max Buffer Size=1024;Persist Security Info=False"; TecanSuppDocsDatabase.Open(); SqlCeCommand cmd = TecanSuppDocsDatabase.CreateCommand(); cmd.CommandText = "SELECT DocID, FileName FROM SuppumentalDocs ORDER BY FileName"; SqlCeDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { allSuppDocsDataGridView.Rows.Add(reader[0].ToString(), reader[1].ToString()); } reader.Dispose(); TecanSuppDocsDatabase.Close(); allSuppDocsDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; }
private int getlastCatID() { Int16 NewCatID = 0; openAppDocDatabase(); SqlCeCommand cmd = TecanAppDocDatabase.CreateCommand(); cmd.CommandText = "SELECT AppCategoryID FROM ApplicationCategories ORDER BY AppCategoryID"; SqlCeDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { NewCatID = Convert.ToInt16(reader[0]); } reader.Dispose(); TecanAppDocDatabase.Close(); return(NewCatID++); }
public static DataTable GetDataTable(String sSQLQuery) { ClearErrorMessage(); ExecuteDataReader(sSQLQuery); DataTable dt = null; if (dr != null) { //if (dr.Depth) //{ dt = new DataTable(); dt.Load(dr); //} dr.Close(); dr.Dispose(); } return(dt); }
private void ResetForm() { try { SqlCeDataReader myReader = null; SqlCeCommand command = new SqlCeCommand("select UniqueValue from UniqueNumbers Where UniqueName='Receipt'", conn); myReader = command.ExecuteReader(); if (myReader.Read()) { textBox1.Text = myReader["UniqueValue"].ToString(); textBox2.Text = DateTime.Today.ToShortDateString(); } myReader.Close(); myReader.Dispose(); textBox3.Text = null; textBox4.Text = null; textBox5.Text = "0.00"; textBox6.Text = "0.00"; textBox7.Text = "0.00"; textBox8.Text = null; textBox9.Text = "0"; textBox10.Text = null; comboBox1.Text = null; comboBox2.Text = null; comboBox3.Text = null; comboBox4.Text = null; datePicker1.DisplayDate = DateTime.Today; datePicker1.SelectedDate = DateTime.Today; if (DOC_NUM != null) { PrintLastTransaction.IsEnabled = true; PrintLastTransaction.Opacity = 1; } } catch (System.Exception ex) { log.Error(ex); } }
private void AddDriver_Click(object sender, RoutedEventArgs e) { AddNewDriver dlg = new AddNewDriver(); dlg.conn = conn; dlg.mode = Mode.MODE_CREATE; dlg.ShowDialog(); try { SqlCeDataReader myReader = null; SqlCeCommand command = new SqlCeCommand("select DRV_COD, DRV_LICENSE, DRV_NAME from Driver", conn); myReader = command.ExecuteReader(); while (myReader.Read()) { int Code = Convert.ToInt32(myReader["DRV_COD"].ToString()); string license = myReader["DRV_LICENSE"].ToString(); string name = myReader["DRV_NAME"].ToString(); if (!dct_drivers.ContainsKey(license)) { dct_drivers.Add(license, name); } if (!drivers.Contains(name)) { drivers.Add(name); } if (!dct_drv_licen.ContainsKey(license)) { dct_drv_licen.Add(license, Code); } } myReader.Close(); myReader.Dispose(); comboBox1.ItemsSource = drivers; } catch (System.Exception ex) { log.Error(ex); } }
public List <GeometryColumn> GetGeometryColumns() { List <GeometryColumn> list = new List <GeometryColumn>(); SqlCeDataReader sqlCeDataReader = _sqlCeDb.GetDataReader(_tableName, null, SortOrder.None) as SqlCeDataReader; if (sqlCeDataReader == null) { return(list); } while (sqlCeDataReader.Read()) { list.Add(new GeometryColumn() { TableName = sqlCeDataReader["G_TABLE_NAME"].ToString(), GeometryType = Convert.ToInt32(sqlCeDataReader["GEOMETRY_TYPE"]) }); } sqlCeDataReader.Close(); sqlCeDataReader.Dispose(); return(list); }
public static long GetCurrentVal(string Sequence) { //string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.dbintegracaoConnectionString"].ConnectionString; string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.ConnectionString"].ConnectionString; long retorno = 0; //MySqlConnection con = new MySqlConnection(ConnectionString); SqlCeConnection con = new SqlCeConnection(ConnectionString); try { con.Open(); //MySqlCommand cmd = new MySqlCommand("SELECT currentval(?Sequence) as currentsequence", con); SqlCeCommand cmd = new SqlCeCommand("SELECT sequence_cur_value FROM sequence_data WHERE sequence_name = @Sequence", con); cmd.Parameters.AddWithValue("@Sequence", Sequence); //MySqlDataReader dr = cmd.ExecuteReader(); SqlCeDataReader dr = cmd.ExecuteReader(); bool HasRows = dr.Read(); if (HasRows) { if (!dr.IsDBNull(0)) { retorno = dr.GetInt64(0); } } dr.Close(); dr.Dispose(); cmd.Dispose(); return(retorno); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } }
public void loadCompatibilities() { // Add Compatibilities to List ArrayList theCompatibilities = new ArrayList(); openDB(); SqlCeCommand cmd = TecanDatabase.CreateCommand(); cmd.CommandText = "SELECT CompatibilityName, CompatibilityID FROM Compatibility ORDER BY CompatibilityName"; SqlCeDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { theCompatibilities.Add(new Compatibilities(reader[0].ToString(), reader[1].ToString())); } reader.Dispose(); TecanDatabase.Close(); compatibilitiesListBox.DataSource = theCompatibilities; compatibilitiesListBox.DisplayMember = "Name"; compatibilitiesListBox.ValueMember = "ID"; }
private void cbx_conn_custm_DropDown(object sender, EventArgs e) { cbx_conn_custm.Items.Clear(); choosebook.Items.Clear(); dt.Rows.Clear(); cbx_conn_custm.Items.Add("Internal Data-Base"); SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.Amdtbse_2ConnectionString); SqlCeCommand comm = conn.CreateCommand(); comm.CommandText = "SELECT * FROM [DB_PATH_LOCAL]"; conn.Open(); dr = comm.ExecuteReader(); dt.Load(dr, LoadOption.PreserveChanges); dgv.DataSource = dt; foreach (DataGridViewRow drw in dgv.Rows) { str = (string)dgv[0, drw.Index].Value; str2 = (string)dgv[1, drw.Index].Value; if (/*dgv[0, drw.Index].Value.ToString()*/ str == "NOT AVAILABLE" || dgv[0, drw.Index].Value == DBNull.Value) { cbx_conn_custm.Items.Add(/*drw.Cells[1].Value.ToString()*/ str2); } else if (/*dgv[0, drw.Index].Value != "NOT AVAILABLE"*/ str != "NOT AVAILABLE" || dgv[0, drw.Index].Value != DBNull.Value) { try { cbx_conn_custm.Items.Add(str); } catch (Exception erty) { } } } dt.Clear(); dr.Dispose(); conn.Close(); comm.Dispose(); dgv.DataSource = null; }
public static string GetParametro(string chave) { //string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.dbintegracaoConnectionString"].ConnectionString; string ConnectionString = ConfigurationManager.ConnectionStrings["prjbase.Properties.Settings.ConnectionString"].ConnectionString; string retorno = string.Empty; //MySqlConnection con = new MySqlConnection(ConnectionString); SqlCeConnection con = new SqlCeConnection(ConnectionString); try { con.Open(); //MySqlCommand cmd = new MySqlCommand("SELECT valor from parametro where chave = ?chave", con); SqlCeCommand cmd = new SqlCeCommand("SELECT valor from parametro where chave = @chave", con); cmd.Parameters.AddWithValue("@chave", chave); //MySqlDataReader dr = cmd.ExecuteReader(); SqlCeDataReader dr = cmd.ExecuteReader(); bool HasRows = dr.Read(); if (HasRows) { retorno = dr.GetString(0); } dr.Close(); dr.Dispose(); cmd.Dispose(); return(retorno); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } }
public SqlCeResultSet(string tableName, SqlCeDb sqlCeDb) { _sqlCeDb = sqlCeDb; _tableName = tableName; if (tableName == "GEOMETRY_COLUMNS") { return; } SqlCeDataReader sqlCeDataReader = sqlCeDb.GetDataReader(tableName, null, SortOrder.None) as SqlCeDataReader; if (sqlCeDataReader == null) { return; } while (sqlCeDataReader.Read()) { object objValue = sqlCeDataReader["AXF_STATUS"]; if (objValue == null || objValue is DBNull || objValue.ToString().Trim() == "0") { _noEditCount++; } else if (objValue.ToString().Trim() == "1") { _addCount++; } else if (objValue.ToString().Trim() == "2") { _modifyCount++; } else if (objValue.ToString().Trim() == "128") { _deleteCount++; } } sqlCeDataReader.Close(); sqlCeDataReader.Dispose(); }