/// <summary> /// 执行查询语句,返回DataTable /// </summary> /// <param name="dc">查询语句</param> /// <param name="db">操作目标数据库</param> /// <returns>DataTable</returns> public static DataTable DataTableQuery(DbCommand dc, Database db) { DataSet ds = new DataSet(); DataTable dt = new DataTable(); try { PrepareCommand(ref dc, db); ds = db.ExecuteDataSet(dc); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; ds.Dispose(); ds = null; } else { ds.Dispose(); ds = null; return null; } } catch (System.Exception e) { throw new Exception(e.Message); } return dt; }
protected void SaveVar_Click(Object sender, EventArgs e) { #region 保存变量修改 dsSrc = LoadDataTable(); int row = 0; //bool error = false; foreach (object o in DataGrid1.GetKeyIDArray()) { int id = int.Parse(o.ToString()); string variablename = DataGrid1.GetControlValue(row, "variablename").Trim(); string variablevalue = DataGrid1.GetControlValue(row, "variablevalue").Trim(); if (variablename == "" || variablevalue == "") { //error = true; continue; } foreach (DataRow dr in dsSrc.Tables["TemplateVariable"].Rows) { if (id.ToString() == dr["id"].ToString()) { dr["variablename"] = variablename; dr["variablevalue"] = variablevalue; break; } } try { if (dsSrc.Tables[0].Rows.Count == 0) { File.Delete(Utils.GetMapPath("../../templates/" + DNTRequest.GetString("path") + "/templatevariable.xml")); dsSrc.Reset(); dsSrc.Dispose(); } else { string filename = Server.MapPath("../../templates/" + DNTRequest.GetString("path") + "/templatevariable.xml"); dsSrc.WriteXml(filename); dsSrc.Reset(); dsSrc.Dispose(); Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); cache.RemoveObject("/Forum/" + DNTRequest.GetString("path") + "/TemplateVariable"); base.RegisterStartupScript("PAGE", "window.location.href='global_templatevariable.aspx?templateid=" + DNTRequest.GetString("templateid") + "&path=" + DNTRequest.GetString("path") + "&templatename=" + DNTRequest.GetString("templatename") + "';"); } } catch { base.RegisterStartupScript("", "<script>alert('无法更新数据库.');window.location.href='global_templatevariable.aspx?templateid=" + DNTRequest.GetString("templateid") + "&path=" + DNTRequest.GetString("path") + "&templatename=" + DNTRequest.GetString("templatename") + "';</script>"); return; } row++; } #endregion }
public DataSet ExecuteReader(SqlCommand pCommand, String pTable) //public DataSet executeReader(MySqlCommand pCommand, String tabla) //public DataSet ExecuteReader(OleDbCommand pCommand, String pTable) { DataSet dsTable = new DataSet(); try { using (SqlDataAdapter adapter = new SqlDataAdapter(pCommand)) //using (MySqlDataAdapter adaptador = new MySqlDataAdapter(pCommand)) //using (OleDbDataAdapter adapter = new OleDbDataAdapter(pCommand)) { pCommand.Connection = conn; dsTable = new DataSet(); adapter.Fill(dsTable, pTable); } return dsTable; } catch (Exception ex) { ex.Source += " SQL: " + pCommand.CommandText.ToString(); Log.WriteException(MethodBase.GetCurrentMethod().Name, ex); throw ex; } finally { if (dsTable != null) { dsTable.Dispose(); } } }
public void Start() { do { DataSet dtsEquipments = new DataSet("Equipments"); EEP_Client_WS.EEP_Client_WS wsEEP_Client_WS = new EEP_Client_WS.EEP_Client_WS(); bool blFlag = false; try { dtsEquipments.ReadXml(@gsEquipmentsFilePath); DataTable dtDistinct = dtsEquipments.Tables[0].DefaultView.ToTable(true, new string[] { "CompanyID", "EquipmentID", "IP", "Port" }); foreach (DataRow dtwEquipment in dtDistinct.Rows) { //blFlag = PingIt(dtwEquipment["IP"].ToString()); blFlag = PingHost(dtwEquipment["IP"].ToString(), Int16.Parse(dtwEquipment["Port"].ToString())); if (!blFlag) wsEEP_Client_WS.Set_AlarmOccur(gsCompanyID , dtwEquipment["EquipmentID"].ToString() , dtwEquipment["EquipmentID"].ToString() + "(" + dtwEquipment["IP"].ToString() + ":"+ dtwEquipment["Port"].ToString() + ")" + ".State" , dtwEquipment["EquipmentID"].ToString() + "(" + dtwEquipment["IP"].ToString() + ":"+ dtwEquipment["Port"].ToString() + ")" + ".State", DateTime.Now); } } catch (Exception ex) { gLogger.ErrorException("EquipmentState.Start", ex); } finally { if (wsEEP_Client_WS != null) { wsEEP_Client_WS.Dispose(); wsEEP_Client_WS = null; } if (dtsEquipments != null) { dtsEquipments.Dispose(); dtsEquipments = null; } } System.Threading.Thread.Sleep(1000 * giEquipmenStateCheck); } while (true); }
static void Main(string[] args) { Console.Title = "增加性别字段"; string connectionString = //数据库连接字串 "Data Source=.\\SQLExpress;Database=student;Trusted_Connection=true;"; SqlConnection connection = new SqlConnection(connectionString);//创建数据库连接实例 connection.Open(); //打开数据库连接 Console.WriteLine("数据库student连接成功!"); SqlCommand cmd = new SqlCommand(); //创建数据查询类实例 cmd.Connection = connection; cmd.CommandText = "ALTER TABLE student_info ADD sex varchar(2)"; cmd.ExecuteNonQuery(); //执行添加sex字段SQL语句 cmd.Dispose(); SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM student_info", "Data Source=.\\SQLExpress;Database=student;Trusted_Connection=true;"); DataSet dataSet = new DataSet(); //创建数据集 adapter.Fill(dataSet); //填充数据集 for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { dataSet.Tables[0].Rows[i][5] = random.Next(2) == 0 ? "男" : "女";//修改性别值 } SqlCommandBuilder builder = new SqlCommandBuilder(adapter);//将数据集更新与数据库协调 adapter.Update(dataSet); //更新数据集到数据库 builder.Dispose(); dataSet.Dispose(); adapter.Dispose(); connection.Close(); //关闭数据库连接 Console.ReadLine(); }
public bool SaveQueue(string fileName) { // TODO: Implement Method - LogManager.SaveQueue() string path = ""; // to be replaced with data table of queue System.Data.DataTable dt = null; path = System.Configuration.ConfigurationSettings.AppSettings["XmlLogPath"]; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } if (!path.EndsWith("\\")) { path = path + "\\"; } System.Data.DataSet ds = new System.Data.DataSet(); ds.Tables.Add(dt); ds.WriteXml(path + fileName, System.Data.XmlWriteMode.IgnoreSchema); ds.Dispose(); return(true); }
protected void btnLogin_Click(object sender, DirectEventArgs e) { DataSet ds = new DataSet(); bool user = DIMERCO.SDK.Utilities.ReSM.CheckUserInfo(tfUserID.Text.Trim(), tfPW.Text.Trim(), ref ds); if (ds.Tables[0].Rows.Count == 1) { DataTable dtuser = ds.Tables[0]; Session["UserID"] = dtuser.Rows[0]["UserID"].ToString(); DataSet ds1 = DIMERCO.SDK.Utilities.LSDK.getUserProfilebyUserList(dtuser.Rows[0]["UserID"].ToString()); if (ds1.Tables[0].Rows.Count == 1) { DataTable dt1 = ds1.Tables[0]; Session["UserName"] = dt1.Rows[0]["fullName"].ToString(); Session["Station"] = dt1.Rows[0]["stationCode"].ToString(); Session["Department"] = dt1.Rows[0]["DepartmentName"].ToString(); Session["CostCenter"] = dt1.Rows[0]["CostCenter"].ToString(); X.AddScript("window.location.reload();"); } else { X.Msg.Alert("Message", "Data Error.").Show(); return; } } else { X.Msg.Alert("Message", "Please confirm your UserID and Password.").Show(); return; } if (ds != null) { ds.Dispose(); } }
protected override void OnLoad(EventArgs e) { SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM student_info", "Data Source=.\\SQLEXPRESS;Initial Catalog=student;Integrated Security=True");//查询数据库 DataSet dataSet = new DataSet(); //创建数据集 adapter.Fill(dataSet); //填充数据集 adapter.Dispose(); //释放数据库连接 //为ListView控件添加列名 listView1.Columns.Add("学号", 60); listView1.Columns.Add("姓名",40); listView1.Columns.Add("年龄", 40); listView1.Columns.Add("年级", 40); listView1.Columns.Add("成绩", 40); listView1.Columns.Add("性别", 40); for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { //为ListView控件添加行 ListViewItem item = listView1.Items.Add(dataSet.Tables[0].Rows[i][0].ToString()); //为ListView控件每行添加数据 for (int j = 1; j < dataSet.Tables[0].Columns.Count; j++) { item.SubItems.Add(dataSet.Tables[0].Rows[i][j].ToString()); } } dataSet.Dispose(); //释放数据集 }
public void FillDDLPost(DropDownList ddlDropDownList) { string strQuery = null; System.Data.DataSet ds = new System.Data.DataSet(); strQuery = "SELECT id,post_name From mlm_user_post Order By post_name ASC"; ddlDropDownList.Items.Clear(); try { ds = objdb.getDataSet(strQuery); if (ds.Tables[0].Rows.Count > 0) { ddlDropDownList.DataSource = ds; ddlDropDownList.DataTextField = "post_name"; ddlDropDownList.DataValueField = "id"; ddlDropDownList.DataBind(); } ddlDropDownList.Items.Insert(0, "Select"); ddlDropDownList.SelectedIndex = 0; } catch (Exception ex) { } finally { ds.Dispose(); } }
public void SelectUser(int x) { try { byte count = 0; SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Users", cKoneksi.Con); SqlCeDataReader dr; if (cKoneksi.Con.State == ConnectionState.Closed) { cKoneksi.Con.Open(); } dr = cmd.ExecuteReader(); if (dr.Read()) { count = 1; } else { count = 0; } dr.Close(); cmd.Dispose(); if (cKoneksi.Con.State == ConnectionState.Open) { cKoneksi.Con.Close(); } if (count != 0) { DataSet ds = new DataSet(); SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM Users", cKoneksi.Con); da.Fill(ds, "Users"); textBoxUser.Text = ds.Tables["Users"].Rows[x][0].ToString(); textBoxPass.Text = ds.Tables["Users"].Rows[x][1].ToString(); checkBoxTP.Checked = Convert.ToBoolean(ds.Tables["Users"].Rows[x][2]); checkBoxTPK.Checked = Convert.ToBoolean(ds.Tables["Users"].Rows[x][3]); ds.Dispose(); da.Dispose(); } else { MessageBox.Show("Data User Kosong", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); buttonClose.Focus(); } } catch (SqlCeException ex) { MessageBox.Show(cError.ComposeSqlErrorMessage(ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } }
public void FillWeek(DropDownList ddlWeek) { string strQuery = null; System.Data.DataSet ds = new System.Data.DataSet(); strQuery = "SELECT distinct trans_week From mlm_transaction_weekwise Order By trans_year ASC"; ddlWeek.Items.Clear(); try { ds = objdb.getDataSet(strQuery); if (ds.Tables[0].Rows.Count > 0) { ddlWeek.DataSource = ds; ddlWeek.DataTextField = "trans_week"; ddlWeek.DataValueField = "trans_week"; ddlWeek.DataBind(); } ddlWeek.Items.Insert(0, "Select"); ddlWeek.SelectedIndex = 0; } catch (Exception ex) { } finally { ds.Dispose(); } }
public DataSet executeReader(MySqlCommand mySqlCommand, String tabla) { DataSet dsTabla = new DataSet(); try { using (MySqlDataAdapter adaptador = new MySqlDataAdapter(mySqlCommand)) { mySqlCommand.Connection = conexion; dsTabla = new DataSet(); adaptador.Fill(dsTabla, tabla); } return dsTabla; } catch (Exception ex) { ex.Source += " SQL: " + mySqlCommand.CommandText.ToString(); Log.Write(MethodBase.GetCurrentMethod().Name, ex); throw ex; } finally { if (dsTabla != null) dsTabla.Dispose(); } }
private void InitialDataBind() { DataSet ds; #region 绑定用户下拉列表 string[] str = new string[3] { "AA", "AG", "PG" }; User user = new User(); this.ddlUser.Items.Clear(); for (int i = 0; i < str.Length; i++) { ds = new DataSet(); ds = user.GetUsersByType(str[i].ToString(), ""); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { string userID = ds.Tables[0].Rows[j]["UserID"].ToString(); string userName = ds.Tables[0].Rows[j]["UserName"].ToString(); ListItem li = new ListItem(userName, userID); this.ddlUser.Items.Add(li); } ds.Dispose(); } #endregion #region 绑定角色 int userid = Convert.ToInt32(this.ddlUser.SelectedValue); FillSelectedRoleList(userid); FillAllRoleList(userid); #endregion }
public System.Data.DataTable GetDataTable(DbCommand SelectCommand) { System.Data.DataTable objDataTable = null; System.Data.DataSet objDataSet = null; try { objDataSet = this.GetDataSet(SelectCommand); if (objDataSet != null) { if (objDataSet.Tables.Count > 0) { objDataTable = objDataSet.Tables[0].Copy(); } } } catch (Exception ex) { throw new Exception("GetDataTable: " + ex.Message); } finally { if (objDataSet != null) { objDataSet.Dispose(); objDataSet = null; } } return(objDataTable); }
public static void CreateMenuJson() { string jsPath = AppDomain.CurrentDomain.BaseDirectory + "/admin/xml/navmenu.js"; System.Data.DataSet dsSrc = new System.Data.DataSet(); dsSrc.ReadXml(configPath); StringBuilder menustr = new StringBuilder(); menustr.Append("var toptabmenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[2])); menustr.Append("\r\nvar mainmenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[0])); menustr.Append("\r\nvar submenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[1])); menustr.Append("\r\nvar shortcut = "); if (dsSrc.Tables.Count < 4) { menustr.Append("[]"); } else { menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[3])); } WriteJsonFile(jsPath, menustr); dsSrc.Dispose(); }
/// <summary> /// При выборе сервера в comboBox получаем его ID из базы /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e) { DataSet DataSet = new System.Data.DataSet(); int index = comboBox1.SelectedIndex; using (SqlConnection cn = new SqlConnection()) { cn.ConnectionString = connection; try { cn.Open(); SqlCommand sCommand = new SqlCommand("Select ID, ServerName from PhyServers", cn); SqlDataAdapter Adapter = new SqlDataAdapter(sCommand); Adapter.Fill(DataSet, "PhyServers"); DataTable work = DataSet.Tables[0]; CurrentServerID = work.Rows[index].Field <byte>(work.Columns[0]); } catch (SqlException ex) { MessageBox.Show("Проблема в подключении\n" + ex.Message, "ECMServersActive", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } DataSet.Dispose(); }
private bool SelectOldCodeList() { string SQLCmd = "",condStr=""; string code = oldCodeEd.Text.Trim(); string desc = oldDescEd.Text.Trim(); code = code.Trim(); if (code != "") condStr += (condStr == "" ? "" : " AND ") + "(a.customerCode LIKE '" + code + Consts.SQL_CMD_ALL_MARKER + "')"; desc = desc.Trim(); if (desc != "") condStr += (condStr == "" ? "" : " AND ") + "(a.name LIKE N'" + desc + Consts.SQL_CMD_ALL_MARKER + desc + Consts.SQL_CMD_ALL_MARKER + "')"; SQLCmd += " SELECT * FROM customer"; if (condStr != "") SQLCmd += " WHERE " + condStr; try { DataSet reportDataSet = new DataSet(); SqlDataAdapter dataAdapter = new SqlDataAdapter(SQLCmd, data.dataLibs.GetMasterConnectionString()); dataAdapter.Fill(reportDataSet); common.myComboBoxItem item; for (int idx = 0; idx < reportDataSet.Tables[0].Rows.Count; idx++) { item = new common.myComboBoxItem(reportDataSet.Tables[0].Rows[idx].ItemArray[0].ToString(), reportDataSet.Tables[0].Rows[idx].ItemArray[1].ToString()); oldCodeLb.Items.Add(item); } reportDataSet.Dispose(); dataAdapter.Dispose(); } catch (Exception er) { common.sysLibs.ShowErrorMessage(er.Message.ToString()); return false; } return true; }
private void guardardatos() { DataSet ds; SqlDataAdapter adapter; try { System.Data.SqlClient.SqlConnection conn; conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; ds = new DataSet(); conn.Open(); SqlCommand command = new SqlCommand("spContacto", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("NombreyApellido", txtNombreyApellido.Text); command.Parameters.AddWithValue("Email", txtEmail.Text); command.Parameters.AddWithValue("Mensaje", txtMensaje.Text); command.ExecuteNonQuery(); adapter = new SqlDataAdapter(command); adapter.Fill(ds); conn.Close(); ds.Dispose(); } catch (Exception ex){ Response.Write(ex.Message); } finally { } }
public void FillEPINType(DropDownList ddlDropDownList) { string strQuery = null; System.Data.DataSet ds = new System.Data.DataSet(); strQuery = "SELECT id,pin_type From mlm_epin_type Order By id ASC"; ddlDropDownList.Items.Clear(); try { ds = clsOdbc.getDataSet(strQuery); if (ds.Tables[0].Rows.Count > 0) { ddlDropDownList.DataSource = ds; ddlDropDownList.DataTextField = "pin_type"; ddlDropDownList.DataValueField = "id"; ddlDropDownList.DataBind(); } ddlDropDownList.Items.Insert(0, "Select"); ddlDropDownList.SelectedIndex = 0; } catch (Exception ex) { } finally { ds.Dispose(); } }
/// <summary> /// 窗体控件的数据绑定 /// </summary> private void DataBindFuntion() { string drawingstr = string.Empty; string sqlstr = string.Empty; string responuser=string.Empty; this.DRAWINGNOcomboBox.Items.Clear(); if (this.DRAWINGNOcomboBox.Text.Length != 0) { this.DRAWINGNOcomboBox.Text.Remove(0); } this.querybtn.Enabled = true; this.DRAWINGNOcomboBox.Items.Clear(); if (this.drawingrbn.Checked == true) { sqlstr = "SELECT DRAWING_NO FROM PLM.PROJECT_DRAWING_TAB where drawing_type is null AND Project_Id = (select T.ID from PROJECT_TAB T where T.NAME='" + this.textBox1.Text.ToString() + "') AND DOCTYPE_ID IN (7) AND DOCTYPE_ID != 71 AND LASTFLAG = 'Y' AND NEW_FLAG = 'Y' AND DELETE_FLAG = 'N' ORDER BY DRAWING_ID DESC"; } else if (this.modifyrbn.Checked == true) { sqlstr = "SELECT DRAWING_NO FROM PLM.PROJECT_DRAWING_TAB where drawing_type is null AND Project_Id = (select T.ID from PROJECT_TAB T where T.NAME='" + this.textBox1.Text.ToString() + "') AND DRAWING_NO IN (SELECT DISTINCT S.MODIFYDRAWINGNO FROM SP_SPOOL_TAB S WHERE S.FLAG = 'Y' AND S.MODIFYDRAWINGNO IS NOT NULL) AND DOCTYPE_ID = 71 AND LASTFLAG = 'Y' AND NEW_FLAG = 'Y' AND DELETE_FLAG = 'N' ORDER BY DRAWING_ID DESC"; } FillComboBox.GetFlowStatus(this.DRAWINGNOcomboBox, sqlstr); DataSet ds = new DataSet(); drawingstr = "SELECT distinct PLM.USER_API.CHINESENAME(RESPONSIBLE_USER) FROM PLM.PROJECT_DRAWING_TAB where Project_Id = (select T.ID from PROJECT_TAB T where T.NAME='" + this.textBox1.Text.ToString() + "') AND DOCTYPE_ID IN (7) AND DOCTYPE_ID != 71 AND LASTFLAG = 'Y' AND NEW_FLAG = 'Y' AND DELETE_FLAG = 'N'"; FillComboBox.GetFlowStatus(this.RESPONSIBLEcb, drawingstr); responuser = "******" + this.textBox1.Text.ToString() + "') AND DOCTYPE_ID IN (7) AND DOCTYPE_ID != 71 AND LASTFLAG = 'Y' AND NEW_FLAG = 'Y' AND DELETE_FLAG = 'N' ORDER BY DRAWING_ID DESC"; User.DataBaseConnect(responuser, ds); this.DrawingsDgv.DataSource = ds.Tables[0]; ds.Dispose(); SetStatus(); }
//初始化用户表 public void initList() { listUser.Clear(); listUser.Columns.Add("用户名", 150, HorizontalAlignment.Center); listUser.Columns.Add("真实姓名", 130, HorizontalAlignment.Center); listUser.Columns.Add("密码", 150, HorizontalAlignment.Center); try { if(sc.getConn().State!=ConnectionState.Open) { sc.Connect(); } string cmdText = "select * from Users"; SqlDataAdapter adapter = new SqlDataAdapter(cmdText, sc.getConn()); DataSet dataSet = new DataSet(); adapter.Fill(dataSet); for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { ListViewItem item = listUser.Items.Add(dataSet.Tables[0].Rows[i][0].ToString()); for (int j = 1; j < dataSet.Tables[0].Columns.Count; j++) { item.SubItems.Add(dataSet.Tables[0].Rows[i][j].ToString()); } } dataSet.Dispose(); adapter.Dispose(); } catch(Exception ex) { MessageBox.Show("初始化用户信息失败:"+ex.Message); } }
public static DataSet ExecuteDataset(string commandText) { SqlConnection cn = null; SqlCommand cmd = null; SqlDataAdapter da = null; DataSet ds = null; try { cn = new SqlConnection(ConnectionString); if (cn.State == ConnectionState.Closed) cn.Open(); cmd = new SqlCommand(commandText, cn); cmd.CommandTimeout = CommandTimeout; cmd.CommandType = CommandType.Text; da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); return ds; } catch (Exception ex) { throw ex; } finally { if (cn.State == ConnectionState.Open) cn.Close(); if (cn != null) cn.Dispose(); if (cmd != null) cmd.Dispose(); if (da != null) da.Dispose(); if (ds != null) ds.Dispose(); } }
public void loadPermissions() { DataSet ds = new DataSet(); try { cPermissions level = new cPermissions(); level.PermissionLevelID = 0; ds = level.prmissionLvlGet(); dgvPrmssnT.DataSource = ds.Tables[0]; dgvPrmssnT.Columns[0].HeaderText = "Permission Level ID"; dgvPrmssnT.Columns[1].HeaderText = "Permission Level"; dgvPrmssnT.Columns[2].HeaderText = "Info"; dgvPrmssnT.Columns[3].HeaderText = "Date Added"; dgvPrmssnT.Columns[0].Visible = false; dgvPrmssnT.Columns[1].Width = 100; dgvPrmssnT.Columns[2].Width = 200; dgvPrmssnT.Columns[2].Width = 200; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { ds.Dispose(); } // pPerEdit.Enabled = false; numP.Enabled = false; txtQtyType.Enabled = false; txtQtyType.Focus(); }
public static void CreateMenuJson() { string jsPath = Utils.GetMapPath(BaseConfigs.GetForumPath.ToLower() + "admin/xml/navmenu.js"); System.Data.DataSet dsSrc = new System.Data.DataSet(); dsSrc.ReadXml(configPath); StringBuilder menustr = new StringBuilder(); menustr.Append("var toptabmenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[2])); menustr.Append("\r\nvar mainmenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[0])); menustr.Append("\r\nvar submenu = "); menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[1])); menustr.Append("\r\nvar shortcut = "); if (dsSrc.Tables.Count < 4) { menustr.Append("[]"); } else { menustr.Append(Utils.DataTableToJSON(dsSrc.Tables[3])); } WriteJsonFile(jsPath, menustr); dsSrc.Dispose(); }
private void AssessorForm_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); string sql1 = "select (SELECT s.INDEXNAME FROM projectapproveindex s WHERE s.IND = t.index_id) ��˼���, t.assesor ����� from projectapprove t where t.projectid = '"+pid+"' order by t.index_id"; User.DataBaseConnect(sql1,ds); approvedgv.DataSource = ds.Tables[0].DefaultView; ds.Dispose(); }
protected void grdPatientPrescriptions_SelectedIndexChanged(object sender, EventArgs e) { AuthenticationManager Authentication = new AuthenticationManager(); string ModuleId; DataView theDV = new DataView((DataTable)Session["UserRight"]); if (Session["TechnicalAreaId"] != null || Session["TechnicalAreaId"].ToString() != "") { if (Convert.ToInt32(Session["TechnicalAreaId"].ToString()) != 0) { ModuleId = "0," + Session["TechnicalAreaId"].ToString(); } else { ModuleId = "0"; } } else { ModuleId = "0"; } theDV.RowFilter = "ModuleId in (" + ModuleId + ")"; DataTable theDT = new DataTable(); theDT = theDV.ToTable(); string theUrl = string.Empty; int patientID = int.Parse(grdPatientPrescriptions.SelectedDataKey.Values["Ptn_pk"].ToString()); Session["PatientVisitID"] = int.Parse(grdPatientPrescriptions.SelectedDataKey.Values["VisitID"].ToString()); base.Session["PatientId"] = patientID; if (Authentication.HasFeatureRight(ApplicationAccess.Dispense, theDT) == false) { theUrl = "frmPharmacy_ReferenceMaterials.aspx"; } else { theUrl = "frmPharmacyDispense_PatientOrder.aspx"; } #region "Refresh Patient Records" IPatientHome PManager; PManager = (IPatientHome)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientHome, BusinessProcess.Clinical"); System.Data.DataSet thePDS = PManager.GetPatientDetails(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["SystemId"]), Convert.ToInt32(Session["TechnicalAreaId"])); //System.Data.DataSet thePDS = PManager.GetPatientDetails(Convert.ToInt32(Request.QueryString["PatientId"]), Convert.ToInt32(Session["SystemId"])); Session["PatientInformation"] = thePDS.Tables[0]; //Session["DynamicLabels"] = thePDS.Tables[23]; thePDS.Dispose(); #endregion Interface.SCM.IDrug thePharmacyManager = (Interface.SCM.IDrug)ObjectFactory.CreateInstance("BusinessProcess.SCM.BDrug, BusinessProcess.SCM"); thePharmacyManager.LockpatientForDispensing(patientID, 0, Session["AppUserName"].ToString(), DateTime.Now.ToString("dd-MMM-yyyy"), true); Response.Redirect(theUrl, false); }
//User Right Function=========== public void CheckUserRight() { try { #region [USER RIGHT] //Checking Session Varialbels======== if (Session["UserName"] != null && Session["UserRole"] != null) { //Checking User Role======== //if (!Session["UserRole"].Equals("Administrator")) //{ //Checking Right of users======= System.Data.DataSet dsChkUserRight = new System.Data.DataSet(); System.Data.DataSet dsChkUserRight1 = new System.Data.DataSet(); dsChkUserRight1 = (DataSet)Session["DataSet"]; DataRow[] dtRow = dsChkUserRight1.Tables[1].Select("FormName ='Material Requisition Report'"); if (dtRow.Length > 0) { DataTable dt = dtRow.CopyToDataTable(); dsChkUserRight.Tables.Add(dt); } if (Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["ViewAuth"].ToString()) == false && Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["PrintAuth"].ToString()) == false) { Response.Redirect("~/Masters/NotAuthUser.aspx"); } //Checking View Right ======== if (Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["ViewAuth"].ToString()) == false) { BtnShow.Visible = false; } //Checking Print Right ======== if (Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["PrintAuth"].ToString()) == false) { ImgBtnPrint.Visible = false; ImgBtnExcel.Visible = false; FlagPrint = true; } dsChkUserRight.Dispose(); //} } else { Response.Redirect("~/Default.aspx"); } #endregion } catch (ThreadAbortException) { } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Establece el consecutivo de la integración de cada uno de los tribunales, así como la fecha en que /// esa integración entro en funciones, para efectos de la Coordinación /// </summary> public int GetNewIntegracion() { SqlConnection oleConne = new SqlConnection(ConfigurationManager.ConnectionStrings["Directorio"].ToString()); SqlDataAdapter dataAdapter; DataSet dataSet = new DataSet(); DataRow dr; int idIntegracion = 0; try { idIntegracion = DataBaseUtilities.GetNextIdForUse("Integraciones", "IdIntegracion", oleConne); const string SqlQuery = "SELECT * FROM Integraciones WHERE IdIntegracion = 0"; dataAdapter = new SqlDataAdapter(); dataAdapter.SelectCommand = new SqlCommand(SqlQuery, oleConne); dataAdapter.Fill(dataSet, "Integraciones"); dr = dataSet.Tables["Integraciones"].NewRow(); dr["IdIntegracion"] = idIntegracion; dr["IdOrganismo"] = idOrganismo; dr["FechaIntegracion"] = DateTime.Now; dr["FechaIntegracionInt"] = DateTimeUtilities.DateToInt(DateTime.Now); dataSet.Tables["Integraciones"].Rows.Add(dr); dataAdapter.InsertCommand = oleConne.CreateCommand(); dataAdapter.InsertCommand.CommandText = "INSERT INTO Integraciones(IdIntegracion,IdOrganismo,FechaIntegracion,FechaIntegracionInt)" + " VALUES(@IdIntegracion,@IdOrganismo,@FechaIntegracion,@FechaIntegracionInt)"; dataAdapter.InsertCommand.Parameters.Add("@IdIntegracion", SqlDbType.Int, 0, "IdIntegracion"); dataAdapter.InsertCommand.Parameters.Add("@IdOrganismo", SqlDbType.Int, 0, "IdOrganismo"); dataAdapter.InsertCommand.Parameters.Add("@FechaIntegracion", SqlDbType.Date, 0, "FechaIntegracion"); dataAdapter.InsertCommand.Parameters.Add("@FechaIntegracionInt", SqlDbType.VarChar, 0, "FechaIntegracionInt"); dataAdapter.Update(dataSet, "Integraciones"); dataSet.Dispose(); dataAdapter.Dispose(); } catch (SqlException ex) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception, IntegracionesModel", 0); } catch (Exception ex) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception, IntegracionesModel", 0); } finally { oleConne.Close(); } return idIntegracion; }
public static void NewBlogSubscribers() { SqlTriggerContext triggContext = SqlContext.TriggerContext; SqlCommand command = null; DataSet insertedDS = null; SqlDataAdapter dataAdapter = null; try { // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); insertedDS = new DataSet(); dataAdapter.Fill(insertedDS); TriggerHandler(connection, ContentType.Blog, insertedDS); } } catch { } finally { try { if (command != null) { command.Dispose(); command = null; } if (dataAdapter != null) { dataAdapter.Dispose(); dataAdapter = null; } if (dataAdapter != null) { dataAdapter.Dispose(); dataAdapter = null; } if (insertedDS != null) { insertedDS.Dispose(); insertedDS = null; } } catch { } } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { dsPubs.Clear(); gros = new SqlDataAdapter("SELECT [Gross] FROM Payments Where [ID] LIKE '%" + id[i].id.ToString() + "%' AND [Year] LIKE '%" + DateTime.Now.Year.ToString() + "%'", Form1.Conn); dsPubs = new DataSet("Pubs"); gros.FillSchema(dsPubs, SchemaType.Source, "Payments"); gros.Fill(dsPubs, "Payments"); dsPubs.Dispose(); }
private void GetFile(string person_id, char type) { string cmd = ""; switch (type) { case 'P': cmd = "research_dir_user.profile_views.get_profile_picture"; break; case 'C': cmd = "research_dir_user.profile_views.get_profile_cv"; break; default: Response.Write("Error:type not defined"); return; } using (Oracle.DataAccess.Client.OracleConnection orCN = new OracleConnection(getConnectionString())) { orCN.Open(); OracleCommand orCmd = new OracleCommand(cmd, orCN); orCmd.CommandType = System.Data.CommandType.StoredProcedure; orCmd.Parameters.Add("p_person_id", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_person_id"].Value = person_id; orCmd.Parameters.Add("r_cur", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output; OracleDataAdapter adapt = new OracleDataAdapter(orCmd); System.Data.DataSet orDS = new System.Data.DataSet(); orCmd.ExecuteNonQuery(); adapt.Fill(orDS); if (orDS.Tables[0].Rows.Count > 0) { System.Data.DataRow dr = orDS.Tables[0].Rows[0]; byte[] barray = (byte[])dr["file_binary"]; Response.ContentType = (String)dr["file_mimetype"]; Response.AddHeader("Content-Disposition", "attachment; filename=" + person_id + "." + dr["file_ext"].ToString() + ";"); Response.AddHeader("Content-Length", barray.Length.ToString()); Response.OutputStream.Write(barray, 0, barray.Length); } else { Response.Write("Error, no image found for person_id '" + person_id + "'"); } orDS.Dispose(); adapt.Dispose(); orCmd.Dispose(); orCN.Close(); orCN.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { var err = false; var msgErr = ""; var requestProduct = ""; try { requestProduct = Page.RouteData.Values["product"].ToString(); } catch { //err = true; //msgErr = "product error"; requestProduct = "1"; } try { source = Page.RouteData.Values["source"].ToString(); } catch { } if (!err) { if (String.IsNullOrEmpty(requestProduct) || !System.Text.RegularExpressions.Regex.IsMatch(requestProduct, "\\d+")) { err = true; msgErr = "product error"; } } if (!err) { var connStr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["PlumDB"].ToString(); System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connStr); conn.Open(); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand( "select product_type.*, product.title as product_title from (PlumDB.dbo.product_type inner join PlumDB.dbo.product on product_type.productid = [product].productid) " + "where product_type.productid = " + requestProduct + " " + " order by typeid asc ", conn ); System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(cmd); System.Data.DataSet ds = new System.Data.DataSet(); adapter.Fill(ds); ds.Dispose(); adapter.Dispose(); cmd.Dispose(); conn.Close(); this.typeidRepeater.DataSource = ds.Tables[0]; this.typeidRepeater.DataBind(); } }
SqlConnection conn = DBConnection.MyConnection(); //得到数据库连接对象 #endregion Fields #region Methods /// <summary> /// 方法用于绑定DataGridView控件 /// </summary> /// <param name="dgv">DataGridView控件</param> /// <param name="sql">SQL语句</param> public void BindDataGridView(DataGridView dgv, string sql) { SqlDataAdapter sda = new SqlDataAdapter(sql, conn);//创建数据适配器对象 DataSet ds = new DataSet();//创建数据集对象 sda.Fill(ds);//填充数据集 dgv.DataSource = ds.Tables[0];//绑定到数据表 ds.Dispose();//释放资源 }
private void FormSTO_Load(object sender, EventArgs e) { buttonConvert.Hide(); try { SqlDataReader dr; string sqls = "SELECT COUNT(TagID),COUNT([TagDuplicate]),COUNT(*) FROM MasterKanban"; SqlCommand cmd = new SqlCommand(sqls, Connect.con2); if (Connect.con2.State == ConnectionState.Closed) { Connect.con2.Open(); } dr = cmd.ExecuteReader(); if (dr.Read()) { labelUniq.Text = "Uniq Item : " + dr[0].ToString(); labelDuplicate.Text = "Duplicate Item : " + dr[1].ToString(); labelTotal.Text = "Total Scan Item : " + dr[2].ToString(); } dr.Close(); cmd.Dispose(); if (Connect.con2.State == ConnectionState.Open) { Connect.con2.Close(); } DataSet ds = new DataSet(); string strSQL = " select distinct(TagDuplicate), count(TagDuplicate) as Jumlah from MasterKanban where TagDuplicate is not null group by TagDuplicate"; SqlDataAdapter da = new SqlDataAdapter(strSQL, Connect.con2); da.Fill(ds, "LogDuplicat"); dataGridListDuplicat.DataSource = ds.Tables[0]; DataGridTableStyle ts = new DataGridTableStyle(); dataGridListDuplicat.TableStyles.Clear(); ts.MappingName = "LogDuplicat"; DataGridTextBoxColumn col1 = new DataGridTextBoxColumn(); col1.HeaderText = "TagDuplicate"; col1.MappingName = "TagDuplicate"; col1.Width = 190; ts.GridColumnStyles.Add(col1); DataGridTextBoxColumn col2 = new DataGridTextBoxColumn(); col2.HeaderText = "Jumlah"; col2.MappingName = "Jumlah"; col2.Width = 40; ts.GridColumnStyles.Add(col2); dataGridListDuplicat.TableStyles.Add(ts); dataGridListDuplicat.Refresh(); ds.Tables.Clear(); da.Dispose(); ds.Dispose(); dataGridListDuplicat.Enabled = true; } catch (SqlException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); this.Close(); } }
public byte[] Get_Restore_Files() { DataSet DataSet = new System.Data.DataSet(); DataSet.Tables.Add("RestoreFiles"); DataSet.Tables["RestoreFiles"].Columns.Add("RESTORE_DATETIME", typeof(DateTime)); DataSet.Tables["RestoreFiles"].Columns.Add("RESTORE_FILE", typeof(String)); StringBuilder strQry = new StringBuilder(); string strFileDirectory = AppDomain.CurrentDomain.BaseDirectory + "Backup"; if (Directory.Exists(strFileDirectory)) { string strDataBaseName = "InteractPayrollClient_"; #if (DEBUG) strDataBaseName = "InteractPayrollClient_Debug_"; #endif string[] filePaths = Directory.GetFiles(@strFileDirectory, strDataBaseName + @"*.bak"); if (filePaths.Length > 0) { for (int intRow = 0; intRow < filePaths.Length; intRow++) { int intDateTimeOffset = filePaths[intRow].IndexOf(strDataBaseName) + strDataBaseName.Length; if (intDateTimeOffset + 19 <= filePaths[intRow].Length) { DataRow drDataRow = DataSet.Tables["RestoreFiles"].NewRow(); drDataRow["RESTORE_FILE"] = filePaths[intRow]; try { DateTime myFileDateTime = DateTime.ParseExact(filePaths[intRow].Substring(intDateTimeOffset, 15), "yyyyMMdd_HHmmss", null); drDataRow["RESTORE_DATETIME"] = myFileDateTime; } catch { } DataSet.Tables["RestoreFiles"].Rows.Add(drDataRow); } } } } DataSet.AcceptChanges(); byte[] bytCompress = clsDBConnectionObjects.Compress_DataSet(DataSet); DataSet.Dispose(); DataSet = null; return(bytCompress); }
public void otrosproductosintangibles() { DataSet ds=new DataSet(); SqlDataAdapter adapter; String tabla=""; String preciosindto = ""; Decimal cambio = 0; Decimal valorcambio = 0; try{ System.Data.SqlClient.SqlConnection conn; conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; conn.Open(); SqlCommand command = new SqlCommand("spselProductosIntangibles", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("IdProveedor", hdfIdProveedor.Value); command.ExecuteNonQuery(); adapter = new SqlDataAdapter(command); adapter.Fill(ds); conn.Close(); if ((ds != null) && (ds.Tables[0].Rows.Count > 0)) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { tabla += " <tr> " + " <td><a href='verproducto.html' class='iframe'><i class='fa fa-xs fa-search'></i> " + ds.Tables[0].Rows[i]["Nombre"].ToString() + " </a></td> " + " <td> </td> "; conversiondemonedas moneda = new conversiondemonedas(); preciosindto = ds.Tables[0].Rows[i]["Tarifa"].ToString(); cambio = moneda.GetConvertion("ARS", "USD"); valorcambio = Decimal.Round(Convert.ToDecimal(ds.Tables[0].Rows[i]["Tarifa"].ToString()) * cambio, 2); tabla +=" <td>Precio para todos los viajeros</td> " + " <td> U$S " + valorcambio + " / AR$ " + preciosindto + " </td> " + " <td class='rojo'></td> " + " <td class='cant'><input type='number' name='cantidad' id='cant_" + ds.Tables[0].Rows[i]["IdProducto"].ToString() + "' value='' placeholder='0' min='0' max='20' size='2' maxlength='2'></td> " + " <td> <input id=" + ds.Tables[0].Rows[i]["IdProducto"].ToString() + " name='chkcompra' type='checkbox' onclick='compraadicional();' ></td> " + " <td>U$S " + valorcambio + " / " + preciosindto + " </td> " + " </tr> "; } } ds.Dispose(); Response.Write(tabla); } catch (Exception ex){ Response.Write(ex.Message); } finally{ } }
public System.Collections.Generic.List <person> GetACClinicalName(string fname, string lname, string hscid) { System.Collections.Generic.List <person> ret = new System.Collections.Generic.List <person>(); using (OracleConnection orCN = new OracleConnection(getConnectionString())) { orCN.Open(); OracleCommand orCmd = new OracleCommand("research_dir_user.profile_views.sel_ac_clinical_person", orCN); orCmd.CommandType = System.Data.CommandType.StoredProcedure; orCmd.Parameters.Add("p_fname", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_fname"].Value = fname; orCmd.Parameters.Add("p_lname", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_lname"].Value = lname; orCmd.Parameters.Add("p_hscid", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_hscid"].Value = hscid; orCmd.Parameters.Add("p_rowCount", OracleDbType.Int16).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_rowCount"].Value = 10; orCmd.Parameters.Add("r_cur", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output; OracleDataAdapter adapt = new OracleDataAdapter(orCmd); System.Data.DataSet orDS = new System.Data.DataSet(); orCmd.ExecuteNonQuery(); adapt.Fill(orDS); foreach (System.Data.DataRow dr in orDS.Tables[0].Rows) { person p = new person(); FacultyDirectoryList l = new FacultyDirectoryList(); p.first_name = dr["first_name"].ToString(); p.last_name = dr["last_name"].ToString(); p.hscid = dr["hscnet_id"].ToString(); p.person_id = dr["person_id"].ToString(); //credentials = dr["title"].ToString(); p.label = p.last_name + ", " + p.first_name + " (" + p.hscid + ")"; p.value = p.person_id; ret.Add(p); } orDS.Dispose(); adapt.Dispose(); orCmd.Dispose(); orCN.Close(); orCN.Dispose(); } return(ret); }
/// <summary> /// 填充损耗的材料类型 /// </summary> private void BindMaterialType() { DataSet ds = new DataSet(); string matypesqlstr = "select type_id, type_desc from mf_materaltype_tab"; User.DataBaseConnect(matypesqlstr, ds); this.typecob.DataSource = ds.Tables[0].DefaultView; ds.Dispose(); this.typecob.DisplayMember = "type_desc"; this.typecob.ValueMember = "type_id"; this.typecob.SelectedIndex = -1; }
/// <summary> /// 填充责任人 /// </summary> private void BindResponser() { DataSet ds = new DataSet(); string usersqlstr = "select username,id from project_user_tab where project_id = '" + User.projectid + "' and catalog = 'Modify'"; User.DataBaseConnect(usersqlstr, ds); this.responsercomb.DataSource = ds.Tables[0].DefaultView; ds.Dispose(); this.responsercomb.DisplayMember = "username"; this.responsercomb.ValueMember = "id"; this.responsercomb.SelectedIndex = -1; }
private void BindWHStatus() { DataSet ds = new DataSet(); string matypesqlstr = "select status_desc, status_id from mf_productstatus_tab"; User.DataBaseConnect(matypesqlstr, ds); this.whstatus.DataSource = ds.Tables[0].DefaultView; ds.Dispose(); this.whstatus.DisplayMember = "status_desc"; this.whstatus.ValueMember = "status_id"; this.whstatus.SelectedIndex = -1; }
public void LoadFacultyInfo() { try { string strConnect = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbprod2.hscnet.hsc.usf.edu)(PORT=1522)))(CONNECT_DATA=(SID=DBAFRZN)(SERVER=DEDICATED)));User Id=sitecore_web;Password=Garbl3ph!em;"; StaffList = new System.Collections.Generic.List <NursingPerson>(); using (OracleConnection dbConnection = new OracleConnection(strConnect)) { dbConnection.Open(); OracleCommand oracleCommand = new OracleCommand("research_dir_user.profile_views.sel_nurse_personnel", dbConnection); oracleCommand.CommandType = System.Data.CommandType.StoredProcedure; oracleCommand.Parameters.Add("r_cur", OracleDbType.RefCursor, ParameterDirection.Output); OracleDataAdapter oracleDataAdapter = new OracleDataAdapter(oracleCommand); System.Data.DataSet dataSet = new System.Data.DataSet(); oracleCommand.ExecuteNonQuery(); oracleDataAdapter.Fill(dataSet); foreach (DataRow dr in dataSet.Tables[0].Rows) { NursingPerson person = new NursingPerson(); person.PERSON_ID = dr["person_id"].ToString().Trim(); person.FIRST_NAME = dr["first_name"].ToString().Trim(); person.LAST_NAME = dr["last_name"].ToString().Trim(); person.ROLE = dr["role"].ToString().Trim(); person.CREDENTIALS = dr["credentials"].ToString().Trim(); person.EMAIL = dr["email"].ToString().Trim(); person.PHONE = dr["phone"].ToString().Trim(); person.PRIMARY_POSITION = dr["primary_position"].ToString().Trim(); person.BUILDING = dr["building"].ToString().Trim(); person.ROOM = dr["room"].ToString().Trim(); StaffList.Add(person); } // Remove duplicate data in case of the person have both staff and faculty status StaffList = StaffList.GroupBy(p => p.PERSON_ID).Select(s => s.FirstOrDefault()).ToList(); dataSet.Dispose(); oracleDataAdapter.Dispose(); oracleCommand.Dispose(); dbConnection.Close(); dbConnection.Dispose(); } } catch (Exception ex) { errorMessage = "Error: " + ex.Message + "<br/>" + ex.StackTrace; errorMessage += ex.InnerException == null ? "" : "<br/>Inner Exception: " + ex.InnerException.Message; Sitecore.Diagnostics.Log.Error("Faculty Direcotry Error - 'LoadFacultyInfo' method: ", errorMessage); } }
private void DrawingComboBox_SelectedIndexChanged(object sender, EventArgs e) { string projectStr = this.ProjectComboBox.ComboBox.SelectedItem.ToString(); string drawingStr = this.DrawingComboBox.ComboBox.SelectedItem.ToString(); sqlStr = @"select SPOOLNAME, BLOCKNO, SYSTEMID, SYSTEMNAME, PIPEGRADE, SURFACETREATMENT,WORKINGPRESSURE, PRESSURETESTFIELD, PIPECHECKFIELD, SPOOLWEIGHT, PAINTCOLOR,CABINTYPE,REMARK, LOGNAME, LOGDATE, DELETEPERSON FROM SP_SPOOL_TAB WHERE PROJECTID = '"+projectStr+"' AND DRAWINGNO = '"+drawingStr+"' AND FLAG = 'N' AND DELETEMARK = 'N' AND DELETEPERSON = '"+User.cur_user+"'"; DataSet MyData = new DataSet(); User.DataBaseConnect(sqlStr, MyData); this.DeletedRecordDgv.DataSource = MyData.Tables[0].DefaultView; MyData.Dispose(); }
// // This is main faculty info, but doesn't contain whole person information, such as Credential and Email sometimes // public string FacultyInfo(string personID) { string json = personID + " couldn't find"; try { if (personID.Contains("Temp_")) { return(""); } string strConnect = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbprod2.hscnet.hsc.usf.edu)(PORT=1522)))(CONNECT_DATA=(SID=DBAFRZN)(SERVER=DEDICATED)));User Id=sitecore_web;Password=Garbl3ph!em;"; using (OracleConnection dbConnection = new OracleConnection(strConnect)) { dbConnection.Open(); OracleCommand oracleCommand = new OracleCommand("research_dir_user.profile_views.sel_research_view", dbConnection); oracleCommand.CommandType = System.Data.CommandType.StoredProcedure; oracleCommand.Parameters.Add("p_person_id", OracleDbType.Long, personID, ParameterDirection.Input); oracleCommand.Parameters.Add("r_research", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_progs", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_title_depts", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_publications", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_degrees", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_lectures", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_positions", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_specialty", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_memberships", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_awards", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_grants", OracleDbType.RefCursor, ParameterDirection.Output); oracleCommand.Parameters.Add("r_patents", OracleDbType.RefCursor, ParameterDirection.Output); OracleDataAdapter oracleDataAdapter = new OracleDataAdapter(oracleCommand); System.Data.DataSet dataSet = new System.Data.DataSet(); oracleCommand.ExecuteNonQuery(); oracleDataAdapter.Fill(dataSet); json = JsonConvert.SerializeObject(dataSet, new Newtonsoft.Json.Converters.DataSetConverter()); dataSet.Dispose(); oracleDataAdapter.Dispose(); oracleCommand.Dispose(); dbConnection.Close(); dbConnection.Dispose(); } } catch (Exception ex) { string error = "Error: " + ex.Message + "<br/>" + ex.StackTrace; error += ex.InnerException == null ? "" : "<br/>Inner Exception: " + ex.InnerException.Message; Sitecore.Diagnostics.Log.Error("Faculty Direcotry Error - 'FacultyInfo' method: ", error); } return(json); }
public void SearchHD(string fname, string lname) { string ret = "Error"; string strConnect = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbprod2.hscnet.hsc.usf.edu)(PORT=1522)))(CONNECT_DATA=(SID=DBAFRZN)(SERVER=DEDICATED)));User Id=hd_search_web;Password=flakSchn0z;"; try { using (OracleConnection orCN = new OracleConnection(strConnect)) { orCN.Open(); OracleCommand orCmd = new OracleCommand("hsc.hd_search.sel_matching_entries", orCN); orCmd.CommandType = System.Data.CommandType.StoredProcedure; orCmd.Parameters.Add("p_first_name", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_first_name"].Value = fname; orCmd.Parameters.Add("p_last_name", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_last_name"].Value = lname; orCmd.Parameters.Add("p_unique_id", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_unique_id"].Value = ""; orCmd.Parameters.Add("p_mdm_id", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_mdm_id"].Value = ""; orCmd.Parameters.Add("p_persons", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output; orCmd.Parameters.Add("p_roles", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output; orCmd.Parameters.Add("p_limit", OracleDbType.Int16).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_limit"].Value = 10; OracleDataAdapter adapt = new OracleDataAdapter(orCmd); System.Data.DataSet orDS = new System.Data.DataSet(); orCmd.ExecuteNonQuery(); adapt.Fill(orDS); ret = Newtonsoft.Json.JsonConvert.SerializeObject(orDS, new Newtonsoft.Json.Converters.DataSetConverter()); orDS.Dispose(); adapt.Dispose(); orCmd.Dispose(); orCN.Close(); orCN.Dispose(); } } catch (Exception ex) { ret = "Error: " + ex.Message + "<br/>" + ex.StackTrace; ret += ex.InnerException == null ? "" : "<br/>Inner Exception: " + ex.InnerException.Message; } Response.Write(ret); }
/// <summary> /// Constructor based on email /// </summary> /// <param name="email"></param> public User(string email) { DataSet dataSet = new DataSet(); // Using configuration determine where to get user information IUserDataProvider iUser = DataProviderFactory.GetUserProvider(); dataSet = iUser.GetUser(email); if (dataSet.Tables["Users"].Rows.Count>0) { LoadDetails(dataSet.Tables["Users"].Rows[0]); } dataSet.Dispose(); }
public void Call_Report_Historic_credit_ym(ReportViewer reportView, string path, int annee, string mois) { // DataTable dt = new DataTable(); try { if (ImplementeConnexion.Instance.Conn.State == ConnectionState.Closed) { ImplementeConnexion.Instance.Conn.Open(); } using (IDbCommand cmd = ImplementeConnexion.Instance.Conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM Affichage_Client_Prets WHERE DATEPART(YEAR, Datepret)=" + annee + " AND DATENAME(month, Datepret) ='" + mois + "'"; da = new SqlDataAdapter((SqlCommand)cmd); ds = new System.Data.DataSet(); //Remplissage du DataSet via DataAdapter da.Fill(ds, "DataSet_Credit"); reportView.LocalReport.DataSources.Clear(); //Source du reportViewr reportView.LocalReport.DataSources.Add(new ReportDataSource("DataSet_Credit", ds.Tables[0])); //Specificier le rapport à charger reportView.LocalReport.ReportEmbeddedResource = path; reportView.RefreshReport(); } } catch (InvalidOperationException ex) { MessageBox.Show("Error " + ex.Message, "Message...", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (SqlException ex) { MessageBox.Show("Error when Selecting data, " + ex.Message, "Selecting data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (ImplementeConnexion.Instance.Conn != null) { if (ImplementeConnexion.Instance.Conn.State == ConnectionState.Open) { ImplementeConnexion.Instance.Conn.Close(); } } if (da != null) { da.Dispose(); } if (ds != null) { ds.Dispose(); } } }
public void Call_Report_Recu_Rembou(ReportViewer reportView, string path, int codeRembou) { // DataTable dt = new DataTable(); try { if (ImplementeConnexion.Instance.Conn.State == ConnectionState.Closed) { ImplementeConnexion.Instance.Conn.Open(); } using (IDbCommand cmd = ImplementeConnexion.Instance.Conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM Affichage_Client_Rembourssement where Numéro = " + codeRembou + ""; da = new SqlDataAdapter((SqlCommand)cmd); ds = new System.Data.DataSet(); //Remplissage du DataSet via DataAdapter //Remplissage du DataSet via DataAdapter da.Fill(ds, "DataSet_recu_Rembou"); reportView.LocalReport.DataSources.Clear(); //Source du reportViewr reportView.LocalReport.DataSources.Add(new ReportDataSource("DataSet_recu_Rembou", ds.Tables[0])); //Specificier le rapport à charger reportView.LocalReport.ReportEmbeddedResource = path; reportView.RefreshReport(); } }catch (InvalidOperationException ex) { MessageBox.Show("Error " + ex.Message, "Message...", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (SqlException ex) { MessageBox.Show("Error when Selecting data, " + ex.Message, "Selecting data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (ImplementeConnexion.Instance.Conn != null) { if (ImplementeConnexion.Instance.Conn.State == System.Data.ConnectionState.Open) { ImplementeConnexion.Instance.Conn.Close(); } } if (da != null) { da.Dispose(); } if (ds != null) { ds.Dispose(); } } }
/// <summary> /// it will select all data from specific table /// convert it into Model Object /// and overwrite current Instance /// </summary> /// <typeparam name="T">Name of Model Object</typeparam> /// <param name="obj"></param> public static void Select <T>(this List <T> obj) { ///----- Remove all objects from list obj.Clear(); ///----- Internal Variables string FullModelName = obj.GetType().FullName.Replace("List", ""); string ModelName = FullModelName.Split('.').Last(); string AssemblyName = FullModelName.Substring(0, FullModelName.IndexOf(".Entities.")); System.Runtime.Remoting.ObjectHandle ModelWrapper = Activator.CreateInstance(AssemblyName, FullModelName); var Model = ModelWrapper.Unwrap(); ModelWrapper = null; /////----- Gathering method which will select data from DB //MethodInfo SelectModel = Model.GetType().GetMethods().ToList().Find(x => x.Name == "Select" && x.GetParameters().Count() == 0); //if (SelectModel == null) { return; } ///----- Gathering Model's Construct that will parse DataRow into Model Object ConstructorInfo cnstrDataRow = Model.GetType().GetConstructors().ToList().Find(x => x.GetParameters().Count() == 1 && x.GetParameters()[0].Name == "Row"); if (cnstrDataRow == null) { return; } ///----- [1].Getting data from DB ///----- [2].Parsing into Model Object ///----- [3].And adding into collection ///----- [1] System.Data.DataSet ds = ((Entity)Model).Select(); if (ds != null && ds.Tables.Count > 0) { foreach (System.Data.DataRow row in ds.Tables[0].Rows) { ///----- [2] T newRow = (T)cnstrDataRow.Invoke(new object[] { row }); ///----- [3] obj.Add(newRow); } ds.Dispose(); } ///----- Clearing up Memory Model = null; ModelName = null; FullModelName = null; }
protected void btn_view_Click(object sender, EventArgs e) { st = "SELECT gold_price,convert(varchar(11),ent_date,106) as ent_date FROM tbl_gold_price WHERE (ent_date BETWEEN convert(datetime,'" + txt_st_date.Text + "') AND convert(datetime, '" + txt_end_date.Text + "'))"; cm = new SqlCommand(st, cn); ds = new DataSet(); da = new SqlDataAdapter(cm); ds.Tables.Clear(); da.Fill(ds, "tbl1"); rptr_gold_price.DataSource = null; rptr_gold_price.DataBind(); rptr_gold_price.DataSource = ds.Tables["tbl1"]; rptr_gold_price.DataBind(); ds.Dispose(); }
private void cboSelectDescription_DropDown(Object sender, System.EventArgs e) { // Retrieve all customers System.Data.DataSet dsAllCustomers = m_oCustomer.Retrieve(); // Bind to the combo box cboSelectDescription.DisplayMember = Customer.FN_CUSTOMER_NAME; cboSelectDescription.DataSource = dsAllCustomers.Tables[0]; cboSelectDescription.ValueMember = Customer.FN_CUSTOMER_ID; cboSelectDescription.SelectedIndex = -1; dsAllCustomers.Dispose(); dsAllCustomers = null; }
private void SetDataGridTableView(DataSet tableDataSet) { dataGridTable.SuspendLayout(); dataGridTable.SetDataBinding(tableDataSet, "tableDataTable"); dataGridTable.ResumeLayout(); if (currentTableDataSet != null) { currentTableDataSet.Dispose(); currentTableDataSet = null; } currentTableDataSet = tableDataSet; }
public void ListFields(string personID) { string ret = "Error"; string strConnect = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbprod2.hscnet.hsc.usf.edu)(PORT=1522)))(CONNECT_DATA=(SID=DBAFRZN)(SERVER=DEDICATED)));User Id=sitecore_web;Password=Garbl3ph!em;"; try { using (OracleConnection orCN = new OracleConnection(strConnect)) { orCN.Open(); OracleCommand orCmd = new OracleCommand("research_dir_user.profile_views.sel_research_view", orCN); orCmd.CommandType = CommandType.StoredProcedure; orCmd.Parameters.Add("p_person_id", OracleDbType.Long, (object)personID, ParameterDirection.Input); orCmd.Parameters.Add("r_research", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_progs", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_title_depts", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_publications", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_degrees", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_lectures", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_positions", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_specialty", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_memberships", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_awards", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_grants", OracleDbType.RefCursor, ParameterDirection.Output); orCmd.Parameters.Add("r_patents", OracleDbType.RefCursor, ParameterDirection.Output); OracleDataAdapter adapt = new OracleDataAdapter(orCmd); System.Data.DataSet orDS = new System.Data.DataSet(); orCmd.ExecuteNonQuery(); adapt.Fill(orDS); ret = Newtonsoft.Json.JsonConvert.SerializeObject(orDS, new Newtonsoft.Json.Converters.DataSetConverter()); orDS.Dispose(); adapt.Dispose(); orCmd.Dispose(); orCN.Close(); orCN.Dispose(); } } catch (Exception ex) { ret = "Error: " + ex.Message + "<br/>" + ex.StackTrace; ret += ex.InnerException == null ? "" : "<br/>Inner Exception: " + ex.InnerException.Message; } Response.Write(ret); }
void IContentEditor.ResetAll() { workSheetDataGrid.DataMember = null; workSheetDataGrid.DataSource = null; workSheetDataSet.Dispose(); workSheetDataSet = workSheetDataSetTemplate.Clone(); try { workSheetDataGrid.SetDataBinding(workSheetDataSet, "Worksheet1"); } catch {} //DataGrid has error while setting databinding in event: "'0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'" m_currentNoteCaption = ""; m_currentNoteID = ""; }
public static System.Collections.Generic.List <person> GetACResearchName(string term) { System.Collections.Generic.List <person> ret = new System.Collections.Generic.List <person>(); using (OracleConnection orCN = HealthIS.Apps.Util.getDBConnection()) { orCN.Open(); OracleCommand orCmd = new OracleCommand("research_dir_user.profile_views.sel_ac_research_person", orCN); orCmd.CommandType = System.Data.CommandType.StoredProcedure; orCmd.Parameters.Add("p_term", OracleDbType.Varchar2).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_term"].Value = term; orCmd.Parameters.Add("p_rowCount", OracleDbType.Int16).Direction = System.Data.ParameterDirection.Input; orCmd.Parameters["p_rowCount"].Value = 10; orCmd.Parameters.Add("r_cur", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output; OracleDataAdapter adapt = new OracleDataAdapter(orCmd); System.Data.DataSet orDS = new System.Data.DataSet(); orCmd.ExecuteNonQuery(); adapt.Fill(orDS); foreach (System.Data.DataRow dr in orDS.Tables[0].Rows) { person p = new person(); p.first_name = dr["first_name"].ToString(); p.last_name = dr["last_name"].ToString(); p.hscid = dr["hscnet_id"].ToString(); p.person_id = dr["person_id"].ToString(); p.label = p.last_name + ", " + p.first_name + " (" + p.hscid + ")"; p.value = p.person_id; ret.Add(p); } orDS.Dispose(); adapt.Dispose(); orCmd.Dispose(); orCN.Close(); orCN.Dispose(); return(ret); } }
/// <summary> /// it will select all data from specific table /// with provided filter criteria /// convert it into Model Object /// and overwrite current Instance /// </summary> /// <typeparam name="T">Name of Model Object</typeparam> /// <param name="obj"></param> /// <param name="objModel">Model Object to filter the results</param> /// <param name="FilterString">string for additional filter the results</param> public static void Select <T>(this List <T> obj, Entity objModel, string FilterString) { ///----- Remove all objects from list obj.Clear(); ///----- Internal Variables string FullModelName = obj.GetType().FullName.Replace("List", ""); string ModelName = FullModelName.Split('.').Last(); ///----- Validation if (FullModelName != objModel.GetType().FullName) { throw new InvalidCastException("Could not convert " + objModel.GetType().FullName + " into object type " + FullModelName); } ///----- Gathering Model's Construct that will parse DataRow into Model Object ConstructorInfo cnstrDataRow = objModel.GetType().GetConstructors().ToList().Find(x => x.GetParameters().Count() == 1 && x.GetParameters()[0].Name == "Row"); if (cnstrDataRow == null) { return; } ///----- [1].Getting data from DB ///----- [2].Parsing into Model Object ///----- [3].And adding into collection ///----- [1] System.Data.DataSet ds = objModel.Select(FilterString); if (ds != null && ds.Tables.Count > 0) { foreach (System.Data.DataRow row in ds.Tables[0].Rows) { ///----- [2] T newRow = (T)cnstrDataRow.Invoke(new object[] { row }); ///----- [3] obj.Add(newRow); } ds.Dispose(); } ///----- Clearing up Memory ModelName = null; FullModelName = null; }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { if (_report != null) { _report.Dispose(); } } // Indicate that the instance has been disposed. _report = null; _disposed = true; } }
//User Right Function=========== public void CheckUserRight() { try { #region [USER RIGHT] //Checking Session Varialbels======== if (Session["UserName"] != null && Session["UserRole"] != null) { System.Data.DataSet dsChkUserRight = new System.Data.DataSet(); System.Data.DataSet dsChkUserRight1 = new System.Data.DataSet(); dsChkUserRight1 = (DataSet)Session["DataSet"]; DataRow[] dtRow = dsChkUserRight1.Tables[1].Select("FormName ='Authorized Purchase Order'"); if (dtRow.Length > 0) { DataTable dt = dtRow.CopyToDataTable(); dsChkUserRight.Tables.Add(dt); // = dt.Copy(); } if (Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["ViewAuth"].ToString()) == false && Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["AddAuth"].ToString()) == false && Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["DelAuth"].ToString()) == false && Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["EditAuth"].ToString()) == false && Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["PrintAuth"].ToString()) == false) { Response.Redirect("~/NotAuthUser.aspx"); } if (Convert.ToBoolean(dsChkUserRight.Tables[0].Rows[0]["AddAuth"].ToString()) == false) { BtnSave.Visible = false; } dsChkUserRight.Dispose(); } else { Response.Redirect("~/Default.aspx"); } #endregion } catch (ThreadAbortException ex) { } catch (Exception ex) { throw new Exception(ex.Message); } }
private void BindGrid() { XmlDocument doc = Doc(); XmlNodeList list = doc.SelectNodes("//link"); if (list.Count > 0) { using (XmlTextReader reader = new XmlTextReader(doc.OuterXml, XmlNodeType.Document, null)) { System.Data.DataSet ds = new System.Data.DataSet(); ds.ReadXml(reader); grid.DataSource = ds; grid.DataKeyNames = new string[] { "id" }; grid.DataBind(); ds.Dispose(); } } }
protected void Page_Load(object sender, EventArgs e) { //查找用户 System.Data.DataSet dsSrc = new System.Data.DataSet(); dsSrc.ReadXml(Page.Server.MapPath("xml/navmenu.config")); //得到顶部菜单相关全局项 DataRow toptabmenudr = dsSrc.Tables["toptabmenu"].Rows[0]; string searchinfo = DNTRequest.GetString("searchinf"); if (searchinfo != "") { IDataReader idr = DatabaseProvider.GetInstance().GetUserInfoByName(searchinfo); int count = 0; bool isexist = false; sb.Append("<table width=\"100%\" style=\"align:center\"><tr>"); while (idr.Read()) { //先找出子菜单表中的相关菜单 isexist = true; if (count >= 3) { count = 0; sb.Append("</tr><tr>"); } count++;//javascript:resetindexmenu('7','3','7,8','global/global_usergrid.aspx'); sb.Append("<td width=\"33%\" style=\"align:left\"><a href=\"#\" onclick=\"javascript:resetindexmenu('7','3','7,8','global/global_edituser.aspx?uid=" + idr["uid"] + "');\">" + idr["username"].ToString().ToString() + "</a></td>"); } idr.Close(); if (!isexist) { sb.Append("没有找到相匹配的结果"); } sb.Append("</tr></table>"); } else { sb.Append("您未输入任何搜索关键字"); } dsSrc.Dispose(); }
public static DataTable ExecuteDataTable(string connectionString, CommandType cmdType, string cmdText, params OracleParameter[] commandParameters) { using (OracleConnection connection = new OracleConnection(connectionString)) { OracleCommand cmd = new OracleCommand(); try { PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); OracleDataAdapter MyAdapter = new OracleDataAdapter(); MyAdapter.SelectCommand = cmd; DataSet ds = new DataSet(); MyAdapter.Fill(ds); cmd.Parameters.Clear(); DataTable table = ds.Tables[0]; ds.Dispose(); connection.Close(); return table; } catch { connection.Close(); throw; } } }