/// <summary> /// 保存数据(数据较少情况下) /// </summary> /// <param name="dataSet"></param> /// <param name="tableName"></param> /// <returns></returns> public bool SaveDataToTable(DataSet dataSet, string tableName) { string strSql = "select * from " + "[" + tableName + "]"; try { if (!dataSet.HasChanges()) { return(true); } DataSet changesDataSet = dataSet.GetChanges(DataRowState.Modified); int result = UpdateDataSet(dataSet, tableName, strSql); dataSet.AcceptChanges(); if (result > 0) { return(true); } else { return(false); } } catch (Exception ex) { LoggerManager.GetILog("MethodName:SaveDataToTable" + ex.StackTrace); return(false); } }
public DataTable FillDataTable( string tableName, string[] dbParams, object[] dbValues) { using (DbConnection _conn = CreateConnection()) { try { DataTable dt = FillDataSet( tableName, dbParams, dbValues).Tables[0]; return(dt); } catch (Exception ex) { LoggerManager.GetILog("GetDataTable:SqlServerConfigInfo-" + ex.StackTrace); return(null); } finally { DisposeConnection(_conn); } } }
/// <summary> /// Constructor. /// </summary> public MySqlConfigInfo() { try { DbCommon.GetDbConfig(ref m_providerName, ref m_connString, this); } catch (CustomDataException ex) { LoggerManager.GetILog("Constructor:SqlServerConfigInfo-" + ex.StackTrace); } }
private void txtPinyin_TextChanged(object sender, System.EventArgs e) { try { if (this.txtPinyin.Text.Equals("")) { return; } //dish.functions.CommValidate cv = new dish.functions.CommValidate(); //string sql = ""; string currentSearchType = ""; DataTable dt = null; if (!Information.IsNumeric(this.txtPinyin.Text)) { if (!this.txtPinyin.Text.Equals("")) { //dt = new MenuManage().GetMenuInfoBySearchCondition(this.txtPinyin.Text); } } else { currentSearchType = "pinyin"; //dt = new MenuManage().GetMenuInfoBySearchCondition(this.txtPinyin.Text, true); } if (dt != null) { this.BindDishCard(dt); } if (!this.dishCards[0].DishName.Equals("") && this.dishCards[1].DishName.Equals("")) { this.DishCards_Click(this.dishCards[0].lblDishName, null); if (this.frmPinyinAndCode == null) { this.frmPinyinAndCode = new frmPinyinAndCode(); } this.frmPinyinAndCode.txtControl.Text = ""; this.txtPinyin.Text = string.Empty; this.txtPinyin.Focus(); } } catch (Exception ex) { MessageBox2.Show(ex.ToString()); LoggerManager.GetILog().Error(ex.StackTrace); } }
public SqlServerConfigInfo() { try { //System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetEntryAssembly().Location); // m_providerName = config.AppSettings.Settings["DataProvider"].Value; // m_connString = config.AppSettings.Settings["ConnectionString"].Value; DbCommon.GetDbConfig(ref m_providerName, ref m_connString, this); } catch (CustomDataException ex) { LoggerManager.GetILog("Constructor:SqlServerConfigInfo-" + ex.StackTrace); } }
//do not need focus on string para method private DataSet FillDataSet(string tbName, string[] dbParams, object[] dbValues) { using (DbConnection _conn = CreateConnection()) { try { return(FillDataset(_conn, tbName, dbParams, dbValues)); } catch (Exception ex) { LoggerManager.GetILog("MethodName:GetDataSet-" + ex.StackTrace); return(null); } finally { DisposeDBConnection(_conn); } } }
public void ExecuteNonQuery( string[] dbParams, object[] dbValues, string tbName, bool containsIdentityColumn = false ) { using (DbConnection _conn = CreateConnection()) { try { ExecuteNonQuery(tbName, dbParams, dbValues, containsIdentityColumn); } catch (Exception ex) { LoggerManager.GetILog("MethodName:[db]-ExecuteNonQuery-" + ex.StackTrace); } finally { DisposeConnection(_conn); } } }