Exemplo n.º 1
0
        public static System.Data.DataTable GetDataTable(string strSQL)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            System.Data.SqlClient.SqlConnectionStringBuilder csb = new System.Data.SqlClient.SqlConnectionStringBuilder();

            csb.DataSource = System.Environment.MachineName;
            csb.DataSource = @"VMSTZHDB08\SZH_DBH_1";
            csb.InitialCatalog = "HBD_CAFM_V3";

            csb.DataSource = "CORDB2008R2";
            csb.InitialCatalog = "Roomplanning";

            // csb.DataSource = "cordb2014";
            // csb.InitialCatalog = "ReportServer";

            csb.DataSource = @"CORDB2008R2";
            csb.InitialCatalog = "COR_Basic_SwissLife";

            csb.IntegratedSecurity = true;

            using (System.Data.Common.DbDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(strSQL, csb.ConnectionString))
            {
                da.Fill(dt);
            }

            return dt;
        }
Exemplo n.º 2
0
        private void ProductTypeForm_Load(object sender, EventArgs e)
        {
            // TODO сделать для обновления
            System.Data.SqlClient.SqlCommand cat_cmd = Producer.Categories.Select(Guid.Empty);
            cat_cmd.Connection = this.cConnection;
            System.Data.SqlClient.SqlDataAdapter catda = new System.Data.SqlClient.SqlDataAdapter(cat_cmd);
            System.Data.DataTable tbl = new System.Data.DataTable("Categories");
            catda.Fill(tbl);
            this.cbxCategories.DataSource = tbl;
            this.cbxCategories.DisplayMember = "CategoryName";
            this.cbxCategories.ValueMember = "CategoryID";
            string col_name = "Category";
            if (!System.Convert.IsDBNull(this.product_type[col_name])) this.cbxCategories.SelectedValue = this.product_type[col_name];
            this.isNewType = (System.Convert.IsDBNull(this.product_type["TypeId"]) || ((int)this.product_type["TypeId"]) < 0);

            string caption = "Добавление нового типа продукта";
            if (!this.isNewType)
            {
                int ptype = -1;
                col_name = "TypeId";
                if (!System.Convert.IsDBNull(this.product_type[col_name]))
                    ptype = (int)this.product_type[col_name];
                col_name = "Name";
                if (!System.Convert.IsDBNull(this.product_type[col_name]))
                    this.tbxProductType.Text = (string)this.product_type[col_name];
                col_name = "Comment";
                if (!System.Convert.IsDBNull(this.product_type[col_name]))
                    this.tbxComment.Text = (string)this.product_type[col_name];

                caption = string.Format("Редактирование типа продукта #{0}", ptype);
            }
            this.Text = caption;
            return;
        }
Exemplo n.º 3
0
 private void cbxCategories_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!this.bBlockContent)
     {
         this.bBlockContent = true;
         System.Data.SqlClient.SqlCommand cmd = null;
         if (this.cbxCategories.SelectedIndex >= 0)
         {
             cmd = Producer.Commands.Products((Guid)this.cbxCategories.SelectedValue, System.Guid.Empty);
         }
         else
         {
             cmd = Producer.Commands.Products(Guid.Empty, System.Guid.Empty);
         }
         cmd.Connection = this.cConnection;
         System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(cmd);
         this.products = new DataTable("Products");
         sda.Fill(this.products);
         this.cbxProducts.DataSource = this.products;
         this.cbxProducts.ValueMember = "ProductID";
         this.cbxProducts.DisplayMember = "ProductName";
         if( this.products.Rows.Count > 0 )
             this.LoadPrices((Guid)this.products.Rows[0]["ProductID"]);
         this.bBlockContent = false;
     }
 }
Exemplo n.º 4
0
        private void ChangePositionForm_Load(object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlDataAdapter sda = null;

            System.Data.SqlClient.SqlCommand prdccmd = Producer.Commands.Products(-1, -1 );
            prdccmd.Connection = this.connection;
            sda = new System.Data.SqlClient.SqlDataAdapter(prdccmd);
            this.products = new System.Data.DataTable("Products");
            sda.Fill(this.products);
            this.cbxProducts.DataSource = this.products;
            this.cbxProducts.DisplayMember = "ProductName";
            this.cbxProducts.ValueMember = "ProductID";
            this.cbxProducts.SelectedValue = this.product_id;

            prdccmd = Producer.Commands.Products( -1, this.product_id );
            prdccmd.Connection = this.connection;
            sda = new System.Data.SqlClient.SqlDataAdapter(prdccmd);
            System.Data.DataTable prods = new System.Data.DataTable("Product");
            sda.Fill(prods);

            System.Data.SqlClient.SqlCommand catccmd = Producer.Commands.ProductCategories();
            catccmd.Connection = this.connection;
            sda = new System.Data.SqlClient.SqlDataAdapter(catccmd);
            this.categories = new System.Data.DataTable("Categories");
            sda.Fill(this.categories);
            this.cbxCategory.DataSource = this.categories;
            this.cbxCategory.DisplayMember = "CategoryName";
            this.cbxCategory.ValueMember = "CategoryID";
            this.cbxCategory.SelectedValue = prods.Rows[0]["Category"];
            //this.block = false;

            //this.tbxCurrentProduct.Text = this.product["ProductName"].ToString();
        }
Exemplo n.º 5
0
 private void ReloadStatistics()
 {
     System.Data.SqlClient.SqlCommand cmd = null;
     string d_member = "";
     string v_member = "";
     if(this.tsmiByReceiver.Checked){
         cmd = Statistics.Contents.ByReceiver(this.receipt, out d_member, out v_member);
     }
     else if (this.tsmiByBuyer.Checked)
     {
         cmd = Statistics.Contents.ByBuyer(this.receipt, out d_member, out v_member);
     }else if( this.tsmiByProductTypes.Checked){
         cmd = Statistics.Contents.ByProductTypes(this.receipt, out d_member, out v_member);
     }
     else if (this.tsmiByCategories.Checked)
     {
         cmd = Statistics.Contents.ByCategories(this.receipt, out d_member, out v_member);
     }
     if (cmd != null)
     {
         System.Data.DataTable content_stat = new DataTable("ContentsStatistics");
         cmd.Connection = this.connection;
         System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(cmd);
         sda.Fill(content_stat);
         this.dgvData.DataSource = content_stat;
         this.dgvData.Columns[d_member].DisplayIndex = 0;
         this.dgvData.Columns[v_member].DisplayIndex = 1;
     }
     else
     {
         MessageBox.Show("Не выбрано ни одного критерия!", "Ошибка");
     }
     return;
 }
Exemplo n.º 6
0
    private System.Data.DataRow GetParameter(string IDParametro, int? IDPortal, int? IDSistema, string IDUsuario)
    {
      // Aca se lee la informacion de la base de datos
      // y se preparan los layers
      string connStr = ValidacionSeguridad.Instance.GetSecurityConnectionString();
      System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connStr);
      conn.Open();

      System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand
        ("SELECT * FROM dbo.SF_VALOR_PARAMETRO(@IDParametro, @IDPortal, @IDSistema, @IDUsuario)", conn);

      System.Data.SqlClient.SqlParameter prm = new System.Data.SqlClient.SqlParameter("@IDParametro", System.Data.SqlDbType.VarChar, 100);
      prm.Value = IDParametro;
      cmd.Parameters.Add(prm);

      prm = new System.Data.SqlClient.SqlParameter("@IDPortal", System.Data.SqlDbType.Int);
      if (IDPortal.HasValue)
      {
        prm.Value = IDPortal.Value;
      }
      else
      {
        prm.Value = null;
      }
      cmd.Parameters.Add(prm);

      prm = new System.Data.SqlClient.SqlParameter("@IDSistema", System.Data.SqlDbType.Int);
      if (IDSistema.HasValue)
      {
        prm.Value = IDSistema.Value;
      }
      else
      {
        prm.Value = null;
      }
      cmd.Parameters.Add(prm);

      prm = new System.Data.SqlClient.SqlParameter("@IDUsuario", System.Data.SqlDbType.VarChar);
      if (IDUsuario != null)
      {
        prm.Value = IDUsuario;
      }
      else
      {
        prm.Value = null;
      }
      cmd.Parameters.Add(prm);

      //     IdParametro, Alcance, ValorTexto, ValorEntero, ValorDecimal, ValorLogico, ValorFechaHora
      cmd.CommandType = System.Data.CommandType.Text;
      System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd);

      System.Data.DataSet ds = new System.Data.DataSet();
      da.Fill(ds);

      conn.Close();

      return ds.Tables[0].Rows[0];
      //return resultado;
    }
Exemplo n.º 7
0
        private void FillDataSet()
        {

            //1. Make a Connection
            System.Data.SqlClient.SqlConnection objCon;
            objCon = new System.Data.SqlClient.SqlConnection();
            objCon.ConnectionString = @"Data Source=(localDB)\v11.0;Initial Catalog = EmployeeProjects; Integrated Security=True;";
            objCon.Open();

            //2. Issue a Command
            System.Data.SqlClient.SqlCommand objCmd;
            objCmd = new System.Data.SqlClient.SqlCommand();
            objCmd.Connection = objCon;
            objCmd.CommandType = CommandType.StoredProcedure;
            objCmd.CommandText = @"pSelEmployeeProjectHours";

            //3. Process the Results
            System.Data.DataSet objDS = new DataSet();
            System.Data.SqlClient.SqlDataAdapter objDA;
            objDA = new System.Data.SqlClient.SqlDataAdapter();
            objDA.SelectCommand = objCmd;
            objDA.Fill(objDS); // objCon.Open() is not needed!
            dataGridView1.DataSource = objDS.Tables[0];

            //4. Clean up code
            objCon.Close();
            dataGridView1.Refresh();
        }
Exemplo n.º 8
0
 //Form 1
 public void dataGrid2(DataTable dt, object textbox)
 {
     System.Data.SqlClient.SqlDataAdapter da;
     string sql = string.Format("SELECT * FROM itemtable where Item_Name LIKE '%{0}%'", textbox);
     da = new System.Data.SqlClient.SqlDataAdapter(sql, con);
     da.Fill(dt);
 }
Exemplo n.º 9
0
 //Form 1
 public void dataGrid(DataTable dt, object table)
 {
     System.Data.SqlClient.SqlDataAdapter da;
     string sql = "SELECT * FROM " + table;
     da = new System.Data.SqlClient.SqlDataAdapter(sql, con);
     da.Fill(dt);
 }
Exemplo n.º 10
0
 public ReturnResult CheckUserAccount(string UserAccount, string UserPassWord)
 {
     ReturnResult ReturnResult = new ReturnResult();
     ConnStr(0);
     System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
     cmd.Connection = conn;
     cmd.CommandType = CommandType.Text;
     cmd.CommandTimeout = 300;
     System.Data.SqlClient.SqlDataAdapter Adp;
     cmd.CommandText = "Select Login_id,Check_result from SchManage.dbo.V_Sys_id where Login_id=@Login_id and Pwd=@PWD"; //只要不是1就不是審核跟啟用
     cmd.Parameters.AddWithValue("@Login_id", UserAccount);
     cmd.Parameters.AddWithValue("@PWD",  GetMD5(UserPassWord.Trim().ToUpper())); 
     Adp = new System.Data.SqlClient.SqlDataAdapter(cmd);
     DataSet DBViewDS = new DataSet();
     try
     {
         Adp.Fill(DBViewDS); 
     }
     catch (Exception ex)
     {
         ReturnResult.ReturnMsgNo = -99;
         ReturnResult.ReturnMsg = "WS的取得CheckUserAccount資料失敗" + ex.Message;
         return ReturnResult;
     }
     if (DBViewDS.Tables.Count == 0)
     {
         ReturnResult.ReturnMsgNo = -98;
         ReturnResult.ReturnMsg = "查詢不到您的帳號";
         return ReturnResult;
     }
     if (DBViewDS.Tables[0].Rows.Count == 0)
     {
         ReturnResult.ReturnMsgNo = -98;
         ReturnResult.ReturnMsg = "查詢不到您的帳號";
         return ReturnResult;
     }
     if (Convert.ToString(DBViewDS.Tables[0].Rows[0]["Login_id"]).ToLower() == UserAccount.Trim().ToLower())
     {
         if (Convert.ToInt32(DBViewDS.Tables[0].Rows[0]["Check_result"]) == 1)
         {
             ReturnResult.ReturnMsgNo = 1;
             ReturnResult.ReturnMsg = "登入成功";
             return ReturnResult;
         }
         else
         {
             ReturnResult.ReturnMsgNo = -97;
             ReturnResult.ReturnMsg = "帳號尚未啟用";
             return ReturnResult;
         }
     }
     else
     {
         ReturnResult.ReturnMsgNo = -96;
         ReturnResult.ReturnMsg = "帳號不符";
         return ReturnResult;
     } 
     return ReturnResult;
 }
Exemplo n.º 11
0
        protected void cmdSearch_OnClick(object source, EventArgs e)
        {
            try
            {

                System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
                conn.ConnectionString = "Server=devrystudentsp10.db.6077598.hostedresource.com;User Id=DeVryStudentSP10;Password=OidLZqBv4;";
                conn.Open();
                // Console.WriteLine(conn.State);
                System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand();
                comm.Connection = conn;

                string SQL = "select usertrackerid, trackkey, value,trackwhen from huber_tracker12 where 1=1";
                if (txtKey.Text.Length > 0)
                {
                    SQL += " and trackkey like @trackkey";
                    comm.Parameters.AddWithValue("@trackkey", "%" + txtKey.Text + "%");
                }
                if (txtValue.Text.Length > 0)
                {
                    SQL += " and value like @value ";
                    comm.Parameters.AddWithValue("@value", "%" + txtValue.Text + "%");
                }
                Response.Write(SQL);
                System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter();
                comm.CommandText = SQL;

                #region "Dataset"
                //this is a dataset
                // System.Data.DataSet ds = new System.Data.DataSet();
                //da.SelectCommand = comm;
                //da.Fill(ds);
                //this is a dataset
                //rptDisplay.DataSource = ds.Tables[0];
                #endregion

                System.Data.SqlClient.SqlDataReader dr;
                dr = comm.ExecuteReader();

                if (dr.HasRows)
                {
                    rptDisplay.DataSource = dr;
                    rptDisplay.DataBind();
                }
            }
            catch (System.Data.SqlClient.SqlException sqlex)
            {
                //throw new would go with the changes to your web.config
                //throw new Exception("Connecting to DB", sqlex.InnerException);

                //this way is "roll your own"
                Response.Redirect("anerrorpage.aspx?msg=Error Connecting To DB");
            }
            catch (Exception ex)
            {
                Response.Write("error!");

            }
        }
Exemplo n.º 12
0
 public CL_cad()
 {
     this.rq_sql = null;
     this.cnx = @"";
     this.oCNX = new System.Data.SqlClient.SqlConnection(this.cnx);
     this.oCMD = null;
     this.oDA = null;
     this.oDS = new DataSet();
 }
Exemplo n.º 13
0
 public System.Data.DataSet m_getRows(string rq_sql, string rows)
 {
     this.oDS = new DataSet();
     this.rq_sql = rq_sql;
     this.oCMD = new System.Data.SqlClient.SqlCommand(rq_sql, this.oCNX);
     this.oDA = new System.Data.SqlClient.SqlDataAdapter(this.oCMD);
     this.oDA.Fill(this.oDS, rows);
     return this.oDS;
 }
Exemplo n.º 14
0
        static RoomClient()
        {
            
            //string ConnectString = "metadata=res://*/Model2.csdl|res://*/Model2.ssdl|res://*/Model2.msl;provider=System.Data.SqlClient;provider connection string=&quot;Server=192.168.2.24,8605;Database=dbroom;User ID=sa;Password=654321;MultipleActiveResultSets=True&quot;";
            //System.Data.SqlClient.SqlConnectionStringBuilder sqlConnection = new System.Data.SqlClient.SqlConnectionStringBuilder();
            //sqlConnection.DataSource = @"192.168.2.24,8605";
            //sqlConnection.ApplicationName = "";
            //sqlConnection.InitialCatalog = "dbroom";
            //sqlConnection.IntegratedSecurity = true;
            //sqlConnection.PersistSecurityInfo = true;
            //sqlConnection.UserID = "sa";
            //sqlConnection.Password ="******";

            //string connectString = "Server=10.21.99.82;Database=SecureDB;User ID=secure;Password=secure;";
            string connectString = "data source=10.21.99.80;initial catalog=SecureDB;persist security info=True;user id=secure;password=secure;MultipleActiveResultSets=True;App=EntityFramework;";
            string dir = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            dir = dir.Remove(dir.LastIndexOf('\\'));
            if (System.IO.File.Exists(dir +@"\Server.txt"))
            {
                string serverSet = System.IO.File.ReadLines(dir + @".\Server.txt").First();
                if (serverSet.Length < 300)
                {
                    connectString = serverSet;
                }
            }

            //System.Data.SqlClient.SqlConnection s = new System.Data.SqlClient.SqlConnection(sqlConnection.ConnectionString);

            //System.Data.EntityClient.EntityConnectionStringBuilder ecsb = new System.Data.EntityClient.EntityConnectionStringBuilder();
            //ecsb.Provider = "System.Data.SqlClient";              
            //ecsb.ProviderConnectionString = sqlConnection.ConnectionString;
            //ecsb.Metadata = @"res://*/Model2.csdl|res://*/Model2.ssdl|res://*/Model2.msl";
            //System.Data.EntityClient.EntityConnection ec = new System.Data.EntityClient.EntityConnection(ecsb.ConnectionString);

            //dbroomClientEntities dbroom = new dbroomClientEntities(ec);
            try
            {
                System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter("Select * from tblHostConfig;", connectString);
                System.Data.DataTable DT = new System.Data.DataTable();
                adapter.Fill(DT);
                adapter.Dispose();
                objUrl = "tcp://" + DT.Rows[0]["IP"] + ":" + DT.Rows[0]["Port"] + "/RoomObj";
                
                System.Runtime.Remoting.Channels.Tcp.TcpChannel tcp = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(0);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tcp, false);
                //var HostData = (from o in dbroom.tblHostConfigs select o).First();
                //objUrl = "tcp://" + HostData.IP + ":" + HostData.Port + "/RoomObj";
            }
            catch (Exception )
            {
                throw new Exception("資料庫讀取失敗");
            }
            roomEvent.RoomEvent += new RoomEventHandler(RoomClient_RoomEvent);
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.Interval = 10000;
            timer.Start();           
        }
Exemplo n.º 15
0
        /// <summary>
        /// 构造函数,接收一个SqlServer数据库连接对象SqlConnection
        /// </summary>
        public SqlDbOperHandler(System.Data.SqlClient.SqlConnection _conn)
        {
            conn = _conn;
            dbType = DatabaseType.SqlServer;

            conn.Open();
            cmd = conn.CreateCommand();
            da = new System.Data.SqlClient.SqlDataAdapter();
        }
Exemplo n.º 16
0
 public static System.Data.DataTable GetDataTable(string sql, System.Data.SqlClient.SqlConnection conn)
 {
     System.Data.SqlClient.SqlDataAdapter adp = new System.Data.SqlClient.SqlDataAdapter(sql, conn);
     adp.MissingSchemaAction = System.Data.MissingSchemaAction.AddWithKey;
     System.Data.DataSet ds = new System.Data.DataSet();
     adp.Fill(ds);
     System.Data.DataTable tbl = ds.Tables[0];
     return tbl;
 }
Exemplo n.º 17
0
 private System.Data.DataSet MyDataSet()
 {
     System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon);
     con.Open();
     da_1 = new System.Data.SqlClient.SqlDataAdapter(sql_string, con);
     System.Data.DataSet dat_set = new System.Data.DataSet();
     da_1.Fill(dat_set, "Employee"); //adapter.Fill(ds); для всех таблиц
     con.Close();
     return(dat_set);
 }
 protected override System.Data.DataTable DataTableFromSQL(string SQLText,
                                                           string databaseName,
                                                           string tablename)
 {
     System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(SQLText, GetConnection(databaseName));
     System.Data.DataTable dt = new System.Data.DataTable();
     da.Fill(dt);
     dt.TableName = tablename;
     return(dt);
 }
Exemplo n.º 19
0
 protected static System.Data.DataTable RunQueryDataTableSqlClient(string sql)
 {
     using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, ConnectionObjectSqlClient))
     {
         System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(cmd);
         System.Data.DataTable dt = new System.Data.DataTable();
         adapter.Fill(dt); // Just pass the DataTable into the SqlDataAdapters Fill Method
         return(dt);
     }
 }
Exemplo n.º 20
0
 private System.Data.DataSet MyDataSet()
 {
     System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(str_con);
     con.Open();
     da_1 = new System.Data.SqlClient.SqlDataAdapter(SQL_string, con);
     System.Data.DataSet data_set = new System.Data.DataSet();
     da_1.Fill(data_set, "Test");
     con.Close();
     return data_set;
 }
Exemplo n.º 21
0
 public override System.Data.Common.DbDataAdapter GetAdapter(string selectCommand, System.Data.Common.DbConnection connection, FastReport.Data.CommandParameterCollection parameters)
 {
     System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(selectCommand, connection as System.Data.SqlClient.SqlConnection);
     foreach (FastReport.Data.CommandParameter p in parameters)
     {
         System.Data.SqlClient.SqlParameter parameter = adapter.SelectCommand.Parameters.Add(p.Name, (System.Data.SqlDbType)p.DataType, p.Size);
         parameter.Value = p.Value;
     }
     return(adapter);
 }
Exemplo n.º 22
0
        //Finalmente, es el turno de definir CrearDataAdapter, el cual aprovecha el método Comando para crear el comando necesario.
        protected override System.Data.IDataAdapter CrearDataAdapter(string procedimientoAlmacenado, params Object[] args)
        {
            var da = new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)Comando(procedimientoAlmacenado));

            if (args.Length != 0)
            {
                CargarParametros(da.SelectCommand, args);
            }
            return(da);
        } // end CrearDataAdapter
Exemplo n.º 23
0
 public System.Data.DataTable RunQueryDataTable(string sql)
 {
     using (System.Data.SqlClient.SqlCommand sqlCommand = new System.Data.SqlClient.SqlCommand(sql, SqlConnection))
     {
         System.Data.DataTable dataTable = new System.Data.DataTable();
         System.Data.SqlClient.SqlDataAdapter sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(sqlCommand);
         sqlDataAdapter.Fill(dataTable); // Just pass the DataTable into the SqlDataAdapters Fill Method
         return(dataTable);
     }
 }
Exemplo n.º 24
0
 private void sqlConnTest_Click(object sender, EventArgs e)
 {
     using (var conn = new System.Data.SqlClient.SqlConnection(@"Data Source=localhost\sqlexpress;Initial Catalog=BIMWEB_Test;Integrated Security=True"))
     {
         conn.Open();
         var adapter = new System.Data.SqlClient.SqlDataAdapter("select * from Sys_UserInfo", conn);
         var dt      = new DataTable();
         adapter.Fill(dt);
     }
 }
Exemplo n.º 25
0
 public DataTable QuerySqlDataTable(string sql)
 {
     using (var con = CreateCon())
     {
         DataTable table = new DataTable();
         System.Data.SqlClient.SqlDataAdapter dapt = new System.Data.SqlClient.SqlDataAdapter(sql, con);
         dapt.Fill(table);
         return(table);
     }
 }
Exemplo n.º 26
0
 private void InitAdapter()
 {
     this._adapter = new System.Data.SqlClient.SqlDataAdapter();
     System.Data.Common.DataTableMapping tableMapping = new System.Data.Common.DataTableMapping();
     tableMapping.SourceTable  = "Table";
     tableMapping.DataSetTable = "ONLclimbers";
     tableMapping.ColumnMappings.Add("iid", "iid");
     tableMapping.ColumnMappings.Add("photo", "photo");
     this._adapter.TableMappings.Add(tableMapping);
 }
Exemplo n.º 27
0
        public System.Data.DataSet consultaSimple(string sql_qry)
        {
            System.Data.SqlClient.SqlDataAdapter adaptador = new System.Data.SqlClient.SqlDataAdapter(sql_qry, con);

            System.Data.DataSet datos = new System.Data.DataSet();

            adaptador.Fill(datos, "resultado");

            return datos;
        }
Exemplo n.º 28
0
        public void UpdateDatabase(System.Data.DataSet ds)
        {
            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon);
            con.Open();
            System.Data.SqlClient.SqlDataAdapter da_1 = new System.Data.SqlClient.SqlDataAdapter(sql_string, con);

            System.Data.SqlClient.SqlCommandBuilder cb = new System.Data.SqlClient.SqlCommandBuilder(da_1);

            cb.DataAdapter.Update(ds.Tables[0]);
        }
Exemplo n.º 29
0
 public DataSet QuerySqlDataSet(string sql)
 {
     using (var con = CreateCon())
     {
         DataSet ds = new DataSet();
         System.Data.SqlClient.SqlDataAdapter dapt = new System.Data.SqlClient.SqlDataAdapter(sql, con);
         dapt.Fill(ds);
         return(ds);
     }
 }
Exemplo n.º 30
0
 private void spesifikasi()
 {
     q = "SELECT MERK,TYPE,PROCESSOR, HDD, RAM, VGA,KONDISI,KODE,WARNA FROM GUDANG";
     if (global.ds.Tables["data2"] != null)
     {
         global.ds.Tables["data2"].Clear();
     }
     ad2 = new System.Data.SqlClient.SqlDataAdapter(q, global.con);
     ad2.Fill(global.ds, "data2");
 }
 private System.Data.DataSet MyDataSet()
 {
     System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon);
     con.Open();
     da_1 = new System.Data.SqlClient.SqlDataAdapter(sql_string, con);
     System.Data.DataSet dat_set = new System.Data.DataSet();
     da_1.Fill(dat_set, "Table_Data_1");
     con.Close();
     return(dat_set);
 }
Exemplo n.º 32
0
        public List <UsuariosView> SP_62_CONSULTAR_USUARIOS()
        {
            Conectar();
            _commandTimeout = 600;

            DataTable           result        = new DataTable();
            List <UsuariosView> listaUsuarios = new List <UsuariosView>();

            try
            {
                System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("SP_62_CONSULTAR_USUARIOS", cnn);
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandTimeout = _commandTimeout;

                System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(command);
                da.Fill(result);

                command.Dispose();
            }
            catch (Exception e)
            {
                result = null;
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                Desconectar();
            }

            if (result != null)
            {
                if (result != null && result.Rows.Count > 0)
                {
                    listaUsuarios = result.AsEnumerable().Select(x => new UsuariosView
                    {
                        IdUsuario              = x.Field <int>("ID_USUARIO"),
                        Usuario                = x.Field <string>("USUARIO"),
                        Clave                  = x.Field <string>("CLAVE"),
                        Nombres                = x.Field <string>("NOMBRES"),
                        Apellidos              = x.Field <string>("APELLIDOS"),
                        Email                  = x.Field <string>("EMAIL"),
                        ForzarContraseña       = x.Field <bool>("FORZAR_CAMBIO"),
                        Foto                   = x.Field <byte[]>("FOTO"),
                        IdEstado               = x.Field <int>("ID_ESTADO"),
                        Roles                  = x.Field <string>("ROLES"),
                        IdUsuarioCreacion      = x.Field <int>("ID_USUARIO_CREACION"),
                        IdUsuarioActualizacion = x.Field <int>("ID_USUARIO_ACTUALIZACION"),
                        FechaHoraCreacion      = x.Field <DateTime>("FECHA_HORA_CREACION"),
                        FechaHoraActualizacion = x.Field <DateTime>("FECHA_HORA_ACTUALIZACION")
                    }).ToList();
                }
            }

            return(listaUsuarios);
        }
Exemplo n.º 33
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start");

            //Bil b = new Bil();
            //try
            //{

            //}
            //catch (Exception)
            //{

            //}
            //finally
            //{
            //    b.Dispose();
            //}

            using (Bil b = new Bil())
            {
                //b.gem
            } // dispose bliver kaldt, og den
              // skal sørge for at lukke og rydde op...



            Console.WriteLine("S**t");


            Bil t = new Bil();

            t.Dispose();


            Console.WriteLine();

            //System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection("...");
            //cn.Open();
            //cn.Dispose();

            using (System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection("..."))
            {
                cn.Open();
                using (System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select * ", cn))
                {
                } // dispose
            }

            //using (System.Random rnd = new Random())
            //{

            //}

            var a = System.IO.File.ReadAllLines(@"c:\temp\data.csv");
        }
Exemplo n.º 34
0
        public string ExportExcel(int userId, System.Collections.Hashtable filters, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            ReportDataObject ds = new ReportDataObject();

            string ArticleCode = null;
            string Description = null;
            string Season      = null;



            if (filters.ContainsKey("ArticleCode"))
            {
                ArticleCode = filters["ArticleCode"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("Description"))
            {
                Description = filters["Description"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("Season") && filters["Season"] != null && !string.IsNullOrEmpty(filters["Season"].ToString()))
            {
                Season = filters["Season"].ToString().Replace("'", "''");
            }

            try
            {
                System.Data.SqlClient.SqlDataAdapter adap = new System.Data.SqlClient.SqlDataAdapter();
                adap.SelectCommand             = new System.Data.SqlClient.SqlCommand("StandardCostPriceOverviewRpt_function_ExportProduct", new System.Data.SqlClient.SqlConnection(Library.Helper.GetSQLConnectionString()));
                adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;

                adap.SelectCommand.Parameters.AddWithValue("@Season", Season);
                adap.SelectCommand.Parameters.AddWithValue("@ArticleCode", ArticleCode);
                adap.SelectCommand.Parameters.AddWithValue("@Description", Description);

                adap.TableMappings.Add("Table", "StandardCostPriceOverviewRpt_ProductSearchResult_View");
                adap.Fill(ds);

                ds.AcceptChanges();

                return(Library.Helper.CreateReportFileWithEPPlus(ds, "StandardCostPriceOverviewRpt"));
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(string.Empty);
            }
        }
Exemplo n.º 35
0
        //---------------------------------------------------------------------
        void OtherSnips1()
        {
            //---------------------------------------------
            System.Data.SqlClient.SqlDataAdapter SqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
            System.Data.DataSet Dataset1 = new System.Data.DataSet();
            Dataset1.Tables.Add(new System.Data.DataTable("Table1"));

            //<Snippet26>
            try
            {
                SqlDataAdapter1.Update(Dataset1.Tables["Table1"]);
            }
            catch (Exception e)
            {
                // Error during Update, add code to locate error, reconcile
                // and try to update again.
            }
            //</Snippet26>

            //---------------------------------------------
            NorthwindDataSet northwindDataSet = new NorthwindDataSet();

            //<Snippet12>
            string xmlData = northwindDataSet.GetXml();
            //</Snippet12>

            //<Snippet13>
            string filePath = "ENTER A VALID FILEPATH";

            northwindDataSet.WriteXml(filePath);
            //</Snippet13>

            //---------------------------------------------
            //<Snippet15>
            NorthwindDataSetTableAdapters.RegionTableAdapter regionTableAdapter =
                new NorthwindDataSetTableAdapters.RegionTableAdapter();

            regionTableAdapter.Insert(5, "NorthWestern");
            //</Snippet15>

            //---------------------------------------------
            //<Snippet16>
            System.Data.SqlClient.SqlConnection sqlConnection1 =
                new System.Data.SqlClient.SqlConnection("YOUR CONNECTION STRING");

            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = "INSERT Region (RegionID, RegionDescription) VALUES (5, 'NorthWestern')";
            cmd.Connection  = sqlConnection1;

            sqlConnection1.Open();
            cmd.ExecuteNonQuery();
            sqlConnection1.Close();
            //</Snippet16>
        }
Exemplo n.º 36
0
        public override int SetSchedule(string description, int id = 0)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            string command           = "CDM_SET_SCHEDULE";

            System.Data.SqlClient.SqlConnection  sqlcnn     = new System.Data.SqlClient.SqlConnection(ConnectionString);
            System.Data.SqlClient.SqlParameter[] parameters = new System.Data.SqlClient.SqlParameter[2];

            try
            {
                sqlcnn.Open();

                parameters[0] = new System.Data.SqlClient.SqlParameter("@ID", id)
                {
                    SqlDbType = System.Data.SqlDbType.Int,
                    Direction = System.Data.ParameterDirection.Input
                };
                parameters[1] = new System.Data.SqlClient.SqlParameter("@DESCRIPTION", description)
                {
                    SqlDbType = System.Data.SqlDbType.VarChar,
                    Size      = 250
                };

                using (System.Data.SqlClient.SqlCommand sqlcmd = new System.Data.SqlClient.SqlCommand(command, sqlcnn))
                {
                    sqlcmd.CommandTimeout = CmdTimeOut;
                    sqlcmd.CommandType    = System.Data.CommandType.StoredProcedure;

                    if ((parameters != null))
                    {
                        sqlcmd.Parameters.AddRange(parameters);
                    }

                    using (System.Data.SqlClient.SqlDataAdapter sqlda = new System.Data.SqlClient.SqlDataAdapter(sqlcmd))
                    {
                        sqlda.Fill(dt);
                    }
                }

                if (dt.Rows.Count > 0)
                {
                    return(int.Parse(dt.Rows[0][0].ToString()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar la función SqlDataProvider.SetSchedule, " + ex.Message, ex);
            }
            finally
            {
                sqlcnn.Close();
            }

            return(0);
        }
Exemplo n.º 37
0
        public static void setupShoppingCartAdapter()
        {
            con.ConnectionString = ConStr;
            cartCmd.Connection   = con;
            cartCmd.CommandType  = System.Data.CommandType.Text;
            cartCmd.CommandText  = "Select * from ShoppingCart order by ProductID";

            cartAdapter = new System.Data.SqlClient.SqlDataAdapter(cartCmd);

            cartAdapter.FillSchema(tblShoppingCart, System.Data.SchemaType.Source);
        }
Exemplo n.º 38
0
        private System.Data.DataSet MyDataSet()
        {
            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon);
            con.Open();

            dataAdap1 = new System.Data.SqlClient.SqlDataAdapter(sql_string, con);
            System.Data.DataSet dataSet = new System.Data.DataSet();
            dataAdap1.Fill(dataSet, "Table_Data_1");
            con.Close();
            return dataSet;
        }
Exemplo n.º 39
0
        public static DataSet PDataset(string select_statement)
        {
            System.Data.SqlClient.SqlConnection _con = new System.Data.SqlClient.SqlConnection();
            _con.ConnectionString = GetConnectionString();
            System.Data.SqlClient.SqlDataAdapter ad = new System.Data.SqlClient.SqlDataAdapter(select_statement, _con);
            DataSet ds = new DataSet();

            ad.Fill(ds);
            _con.Close();
            return(ds);
        }
        public ActionResult startADODOTNETQuery()
        {
            string connectionstring = "Data Source=(localdb)\\LocalInstance;Initial Catalog=AdventureWorks2012;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
            string QUERY            = "SELECT * FROM RANDOMDATA";

            System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(QUERY, connectionstring);
            DataSet SpoolClients = new DataSet();

            adapter.Fill(SpoolClients, "RANDOMDATA");
            return(View("Index"));
        }
        public DataTable check_ProductInstock(String qty)
        {
            connectdb();
            sql             = "Select * from check_ProductInStock where Qty <= '" + qty + "'";
            cmd.CommandText = sql;
            da = new System.Data.SqlClient.SqlDataAdapter(sql, cn);
            DataTable get = new DataTable();

            da.Fill(get);
            return(get);
        }
Exemplo n.º 42
0
        public static void setupRoleAdapter()
        {
            con.ConnectionString = ConStr;
            roleCmd.Connection   = con;
            roleCmd.CommandType  = System.Data.CommandType.Text;
            roleCmd.CommandText  = "Select * from RoleInfo order by RoleName";

            roleAdapter = new System.Data.SqlClient.SqlDataAdapter(roleCmd);

            roleAdapter.FillSchema(tblRoleData, System.Data.SchemaType.Source);
        }
Exemplo n.º 43
0
 public DataTable Search_Data(string query)
 {
     Conexion conn = new Conexion();
     conn.Begin_conexion();
     System.Data.SqlClient.SqlDataAdapter qu;
     DataSet ds = new DataSet();
     qu = new System.Data.SqlClient.SqlDataAdapter(query, conn.conexion);
     qu.Fill(ds);
     conn.conexion.Close();
     return ds.Tables[0];
 }
        public DataTable getProduct_instock()
        {
            connectdb();
            sql             = "Select *from check_ProductInStock";
            cmd.CommandText = sql;
            da = new System.Data.SqlClient.SqlDataAdapter(sql, cn);
            DataTable get = new DataTable();

            da.Fill(get);
            return(get);
        }
Exemplo n.º 45
0
        public static void setupUserDataAdapter()
        {
            con.ConnectionString = ConStr;
            userCmd.Connection   = con;
            userCmd.CommandType  = System.Data.CommandType.Text;
            userCmd.CommandText  = "Select * from UserData order by userID";

            userAdapter = new System.Data.SqlClient.SqlDataAdapter(userCmd);

            userAdapter.FillSchema(tblUserData, System.Data.SchemaType.Source);
        }
Exemplo n.º 46
0
        public static void setupProdAdapter()
        {
            con.ConnectionString = ConStr;
            prodCmd.Connection   = con;
            prodCmd.CommandType  = System.Data.CommandType.Text;
            prodCmd.CommandText  = "Select * from product order by ProductID";

            prodAdapter = new System.Data.SqlClient.SqlDataAdapter(prodCmd);

            prodAdapter.FillSchema(product, System.Data.SchemaType.Source);
        }
Exemplo n.º 47
0
 public System.Data.DataTable SelectUserData()
 {
     this.Query         = "SELECT Name,Email,Job,convert(varchar, Date, 6) as Date FROM [dbo].[User]";
     this.SqlConnection = new System.Data.SqlClient.SqlConnection(this.AzureDataBaseConnectionString());
     this.SqlConnection.Open();
     this.SqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(this.Query, this.SqlConnection);
     System.Data.DataTable DataTable = new System.Data.DataTable();
     this.SqlDataAdapter.Fill(DataTable);
     this.SqlConnection.Close();
     return(DataTable);
 }
Exemplo n.º 48
0
 /// <summary>
 /// Get the dataset returned by the SQL statement when executed on the connected database.
 /// Original code from lecture slides:
 /// <code>
 /// // Get the data set generated by the sqlStatement
 /// public DataSet getDataSet(string sqlStatement)
 /// {
 ///     DataSetdataSet;
 ///     // create the object dataAdapterto manipulate a table from the database StudentDissertationsspecified by connectionToDB
 ///     dataAdapter= newSystem.Data.SqlClient.SqlDataAdapter(sqlStatement,       connectionToDB);
 ///     // create the dataset
 ///     dataSet= newcSystem.Data.DataSet();
 ///     dataAdapter.Fill(dataSet);
 ///     //return the dataSet
 ///     return dataSet;
 /// }
 /// </code>
 /// </summary>
 /// <param name="sqlStatement">An SQL statement to execute in the database</param>
 /// <returns>The dataset output by the input SQL statement</returns>
 public System.Data.DataSet GetDataSet(string sqlStatement)
 {
     System.Data.DataSet dataSet;
     // create the object dataAdapter
     dataAdapter = new System.Data.SqlClient.SqlDataAdapter(sqlStatement, dbConnection);
     // create the dataset
     dataSet = new System.Data.DataSet();
     dataAdapter.Fill(dataSet);
     //return the dataSet
     return(dataSet);
 }
        private System.Data.DataSet DataSet()                                                          //connects to the database and fills the dataset
        {
            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon); //create a variable of sqlconnection type
            con.Open();                                                                                //open the connection
            da1 = new System.Data.SqlClient.SqlDataAdapter(sql_string, con);                           //setting the sql data adapter
            System.Data.DataSet dat_set = new System.Data.DataSet();                                   //creating the data set
            da1.Fill(dat_set, "Table_Data_1");                                                         //filling the dataset and naming the fill table_data_1

            con.Close();                                                                               //closing the connection
            return(dat_set);                                                                           //returning the dataset
        }
Exemplo n.º 50
0
 /// <summary>
 /// 设计器支持所需的方法 - 不要使用代码编辑器修改
 /// 此方法的内容。
 /// </summary>
 private void InitializeComponent()
 {
     this.cn                = new System.Data.SqlClient.SqlConnection();
     this.daInbox           = new System.Data.SqlClient.SqlDataAdapter();
     this.dsMessage1        = new LIMS.Message.dsMessage();
     this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
     this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
     ((System.ComponentModel.ISupportInitialize)(this.dsMessage1)).BeginInit();
     this.Message.InitializeRow += new Infragistics.WebUI.UltraWebGrid.InitializeRowEventHandler(this.Message_InitializeRow);
     this.Del.Click             += new Infragistics.WebUI.WebDataInput.ClickHandler(this.Del_Click);
     //
     // cn
     //
     this.cn.ConnectionString = "workstation id=QDMT;packet size=4096;user id=sa;integrated security=SSPI;data sou" +
                                "rce=\".\";persist security info=False;initial catalog=lims";
     //
     // daInbox
     //
     this.daInbox.InsertCommand = this.sqlInsertCommand1;
     this.daInbox.SelectCommand = this.sqlSelectCommand1;
     this.daInbox.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
         new System.Data.Common.DataTableMapping("Table", "收件箱", new System.Data.Common.DataColumnMapping[] {
             new System.Data.Common.DataColumnMapping("ID", "ID"),
             new System.Data.Common.DataColumnMapping("标题", "标题"),
             new System.Data.Common.DataColumnMapping("日期", "日期"),
             new System.Data.Common.DataColumnMapping("发件人", "发件人"),
             new System.Data.Common.DataColumnMapping("已阅", "已阅"),
             new System.Data.Common.DataColumnMapping("收件人ID", "收件人ID")
         })
     });
     //
     // dsMessage1
     //
     this.dsMessage1.DataSetName = "dsMessage";
     this.dsMessage1.Locale      = new System.Globalization.CultureInfo("zh-CN");
     //
     // sqlSelectCommand1
     //
     this.sqlSelectCommand1.CommandText = "SELECT ID, 标题, 发送时间 AS 日期, 发件人, 已阅, 收件人ID FROM 收件箱";
     this.sqlSelectCommand1.Connection  = this.cn;
     //
     // sqlInsertCommand1
     //
     this.sqlInsertCommand1.CommandText = "INSERT INTO 收件箱(标题, 发送时间, 发件人, 已阅, 收件人ID) VALUES (@标题, @发送时间, @发件人, @已阅, @收件人ID);" +
                                          " SELECT ID, 标题, 发送时间 AS 日期, 发件人, 已阅, 收件人ID FROM 收件箱";
     this.sqlInsertCommand1.Connection = this.cn;
     this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@标题", System.Data.SqlDbType.NVarChar, 1073741823, "标题"));
     this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发送时间", System.Data.SqlDbType.DateTime, 8, "日期"));
     this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@发件人", System.Data.SqlDbType.NVarChar, 10, "发件人"));
     this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@已阅", System.Data.SqlDbType.Bit, 1, "已阅"));
     this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@收件人ID", System.Data.SqlDbType.Int, 4, "收件人ID"));
     this.Load += new System.EventHandler(this.Page_Load);
     ((System.ComponentModel.ISupportInitialize)(this.dsMessage1)).EndInit();
 }
Exemplo n.º 51
0
 public DataTable EjecutarProcedimientoAlmacenado(string nombreProceso,string datos)
 {
     Conexion conn = new Conexion();
     conn.Begin_conexion();
     System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(nombreProceso);
     command.CommandType = CommandType.StoredProcedure;
     string cadenaProcedimiento = nombreProceso + datos;
     System.Data.SqlClient.SqlDataAdapter oAdapter = new System.Data.SqlClient.SqlDataAdapter(cadenaProcedimiento,conn.conex);
     DataTable oTabla = new DataTable();
     oAdapter.Fill(oTabla);
     return oTabla;
 }
Exemplo n.º 52
0
        private System.Data.DataSet MyDataSet()
        {
            System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(strCon);
            // SqlConnection will use our connection string in strCon to connect to the database.
            con.Open();//we open a connection to the database.
            da_1 = new System.Data.SqlClient.SqlDataAdapter(sql_string, con);//which records and which database
            System.Data.DataSet dat_set = new System.Data.DataSet();//l hold all the records from the table.
            da_1.Fill(dat_set, "Table_Data_1");

            con.Close( );
           
     return dat_set;
        }
Exemplo n.º 53
0
 //this takes a SQL select and returns a dataset
 public System.Data.DataSet GetDataSet(string SQL)
 {
     if (_connection.State != System.Data.ConnectionState.Open)
         {
             OpenConnection(connectionstring);
         }
     System.Data.SqlClient.SqlDataAdapter da = new  System.Data.SqlClient.SqlDataAdapter ();
     System.Data.DataSet ds = new System.Data.DataSet();
     _command.Connection = _connection;
     _command.CommandText = SQL;
     da.SelectCommand = _command;
     da.Fill(ds);
     return ds;
 }
Exemplo n.º 54
0
 protected System.Data.DataTable getData(string sql)
 {
     try
     {
         System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(sql, conNo);
         System.Data.DataTable dtable = new System.Data.DataTable();
         adapter.Fill(dtable);
         return dtable;
     }
     catch(System.Exception  ex)
     {
         conCloseNo();
         return null;
     }
 }
Exemplo n.º 55
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlConnection _SqlConnection = new System.Data.SqlClient.SqlConnection();
            _SqlConnection.ConnectionString = "Server=tcp:iaz43o1slt.database.windows.net,1433;Database=NewCustomerDb2;User ID=Singhav@iaz43o1slt;Password=Tirlok_0173;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;";

            System.Data.SqlClient.SqlCommand _SqlCommand = new System.Data.SqlClient.SqlCommand("Select * From customer", _SqlConnection);
            System.Data.SqlClient.SqlDataAdapter _SqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter();
            _SqlDataAdapter.SelectCommand = _SqlCommand;

            DataTable _DataTable = new DataTable();
            _DataTable.Locale = System.Globalization.CultureInfo.InvariantCulture;

            _SqlDataAdapter.Fill(_DataTable);
            GridView1.DataSource = _DataTable;
            GridView1.DataBind();
        }
Exemplo n.º 56
0
 private void cbxCategories_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!this.bBlockContent && !System.Convert.IsDBNull( this.cbxCategories.SelectedValue )){
         Guid cat_id = (Guid)this.cbxCategories.SelectedValue;
         System.Data.SqlClient.SqlCommand tp_cmd = Producer.ProductTypes.Select(cat_id);
         tp_cmd.Connection = this.cConnection;
         System.Data.SqlClient.SqlDataAdapter tpda = new System.Data.SqlClient.SqlDataAdapter(tp_cmd);
         this.types_table = new System.Data.DataTable("Types");
         tpda.Fill(this.types_table);
         this.clbxTypes.DataSource = this.types_table;
         this.clbxTypes.DisplayMember = "Name";
         this.clbxTypes.ValueMember = "TypeId";
         this.RefreshProductList(cat_id, null );
     }
     return;
 }
Exemplo n.º 57
0
        private void ByMonths(object sender, EventArgs e)
        {
            try
            {
                System.Data.SqlClient.SqlCommand mnth = Statistics.Purchases.ByMonths();
                mnth.Connection = this.connection;
                System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(mnth);
                System.Data.DataTable st = new System.Data.DataTable("Summary");
                sda.Fill(st);

                ZedGraph.GraphPane pane = this.zgcStatistics.GraphPane;
                pane.CurveList.Clear();
                pane.GraphObjList.Clear();

                pane.YAxis.Title.Text = "Сумма, р";
                ZedGraph.PointPairList list = new ZedGraph.PointPairList();
                foreach (System.Data.DataRow row in st.Rows)
                {
                    int year = 1970;
                    int month = 1;
                    if(!System.Convert.IsDBNull(row["Year"]) &&
                       !System.Convert.IsDBNull(row["Month"]) ){
                        year = (int)row["Year"];
                        month = (int)row["Month"];
                        System.DateTime dt = new DateTime(year, month, 1);
                        ZedGraph.XDate xDate = new ZedGraph.XDate(dt);
                        decimal val = (decimal)row["Summary"];
                        list.Add(xDate.XLDate, (double)val);
                    }
                }
                ZedGraph.BarItem curve = pane.AddBar("", list, Color.Blue);

                // Для оси X установим календарный тип
                pane.XAxis.Type = ZedGraph.AxisType.Date;

                // pretty it up a little
                pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
                pane.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);

                // Tell ZedGraph to calculate the axis ranges
                this.zgcStatistics.AxisChange();
                this.zgcStatistics.Invalidate();
            }catch (System.Exception ex){
                MessageBox.Show(ex.Message);
            }
            return;
        }
Exemplo n.º 58
0
        private void MakersListForm_Load(object sender, EventArgs e)
        {
            this.lvMakers.Columns.Add("№", 30);
            this.lvMakers.Columns.Add("Идентификатор", 30);
            this.lvMakers.Columns.Add("Наименование организации", 190);
            this.lvMakers.Columns.Add("Тип", 50);
            this.lvMakers.Columns.Add("Продавец", 50);
            //this.lvMakers.Columns.Add("Создан", 50);

            System.Data.SqlClient.SqlCommand cmd = Producer.Maker.Select(-1);
            cmd.Connection = this.cConnection;
            System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(cmd);
            this.makers = new System.Data.DataTable("Makers");
            sda.Fill(this.makers);

            this.RefreshMakersList();
        }
Exemplo n.º 59
0
 protected System.Data.DataTable doAddUpdateDelete(System.Data.SqlClient.SqlCommand sql, bool ReturnDataTable)
 {
     try
     {
         sql.Connection = conNo;
         sql.CommandType = System.Data.CommandType.StoredProcedure;
         System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(sql);
         System.Data.DataTable dtable = new System.Data.DataTable();
         adapter.Fill(dtable);
         return dtable;
     }
     catch (System.Exception ex)
     {
         conCloseNo();
         return null;
     }
 }
Exemplo n.º 60
0
        private void EditCompanyForm_Load(object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlCommand cmd = Brands.Companies.Select(Guid.Empty);
            cmd.Connection = this.connection;
            System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(cmd);
            System.Data.DataTable companies = new System.Data.DataTable("Companies");
            sda.Fill(companies);
            DataRow dr = companies.NewRow();
            dr["CompanyName"] = "Компания не выбрана";
            dr["CompanyID"] = DBNull.Value;
            companies.Rows.InsertAt(dr, 0);
            this.cbxCompanies.DataSource = companies;
            this.cbxCompanies.DisplayMember = "CompanyName";
            this.cbxCompanies.ValueMember = "CompanyID";
            if (this.parent != null)
                this.cbxCompanies.SelectedValue = this.parent["CompanyID"];
            else if (!System.Convert.IsDBNull(this.company["ParentID"]))
                this.cbxCompanies.SelectedValue = this.company["ParentID"];
            else
                this.cbxCompanies.SelectedValue = DBNull.Value;

            // A new company or existing?
            if (this.company.RowState == DataRowState.Unchanged ||
                this.company.RowState == DataRowState.Added)
            {
                this.Text = string.Format("Редактирование компании ID: {0}", this.company["CompanyID"]);
                string col_name = "CompanyName";
                if (!System.Convert.IsDBNull(this.company[col_name]))
                    this.tbxCompanyName.Text = (string)this.company[col_name];
                col_name = "Address";
                if (!System.Convert.IsDBNull(this.company[col_name]))
                    this.tbxAddress.Text = (string)this.company[col_name];
                col_name = "WebSite";
                if (!System.Convert.IsDBNull(this.company[col_name]))
                    this.tbxWebAddress.Text = (string)this.company[col_name];
                col_name = "Phones";
                if (!System.Convert.IsDBNull(this.company[col_name]))
                    this.tbxPhones.Text = (string)this.company[col_name];
            }
            else
            {
                this.Text = "Создание новой компании";
            }
            return;
        }