コード例 #1
0
        public static void Run(string path, int field)
        {
            string directory = Path.GetDirectoryName(path);
            string file      = Path.GetFileName(path);

            using (OleDbConnection cnn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + directory + @";Extended Properties=""Text;HDR=No;FMT=Delimited"""))
            {
                using (OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM " + file, cnn))
                {
                    cnn.Open();

                    using (OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
                    {
                        string s;

                        if (field == -1)
                        {
                            while (dr.Read())
                            {
                                for (int i = 0; i < dr.FieldCount; i++)
                                {
                                    s = dr.GetValue(i) as string;
                                }
                            }
                        }
                        else
                        {
                            while (dr.Read())
                            {
                                s = dr.GetValue(field) as string;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string          connString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = candidati.accdb";
            OleDbConnection conexiune  = new OleDbConnection(connString);
            OleDbCommand    comanda    = new OleDbCommand("SELECT * FROM candidati", conexiune);

            try
            {
                conexiune.Open();
                OleDbDataReader reader = comanda.ExecuteReader();
                while (reader.Read())
                {
                    ListViewItem itm = new ListViewItem(reader["cnp"].ToString());
                    //itm.Add(reader["cetatenie"].ToString());
                    itm.SubItems.Add(reader["cetatenie"].ToString());
                    itm.SubItems.Add(reader["nume"].ToString());
                    itm.SubItems.Add(reader["initiala_tatalui"].ToString());
                    itm.SubItems.Add(reader["prenume"].ToString());
                    itm.SubItems.Add(reader["sex"].ToString());
                    itm.SubItems.Add(reader["adresa"].ToString());
                    itm.SubItems.Add(reader["numar_telefon"].ToString());
                    itm.SubItems.Add(reader["email"].ToString());


                    candidati_lv.Items.Add(itm);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conexiune.Close();
            }
        }
コード例 #3
0
        public LotteryTicketPanel GetLotteryTicketPanel(GameMode gameMode)
        {
            LotteryTicketPanelSetup lotteryTicketPanel = new LotteryTicketPanelSetup();

            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand("SELECT * FROM lottery_ticket_panel WHERE game_cd = ? AND active = true;", conn))
                {
                    command.Parameters.AddWithValue("game_cd", gameMode);
                    conn.Open();
                    using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            lotteryTicketPanel.Cols            = int.Parse(reader["cols"].ToString());
                            lotteryTicketPanel.Rows            = int.Parse(reader["rows"].ToString());
                            lotteryTicketPanel.Max             = int.Parse(reader["max"].ToString());
                            lotteryTicketPanel.Min             = int.Parse(reader["min"].ToString());
                            lotteryTicketPanel.GameDigitCount  = int.Parse(reader["game_digit"].ToString());
                            lotteryTicketPanel.NumberDirection = ClassReflectionUtil.ConvertToNumberDirection(int.Parse(reader["num_dir"].ToString()));
                        }
                    }
                }
            return(lotteryTicketPanel);
        }
コード例 #4
0
        /// <summary> agrega un dia al grupo indicado </summary>
        internal static bool agregarDiaClase(DateTime dia, int idGrupo)
        {
            try
            {
                //verificar que el dia no exista
                conection.Open();
                comand.CommandText =
                    "SELECT * FROM DiasClase " +
                    "WHERE fecha=#" + dia.ToString("MM'/'dd'/'yy") + "# " +
                    "AND idGrupo=" + idGrupo;
                reader = comand.ExecuteReader();

                //si ya existe se retorna false y no se agrega el dia
                if (reader.Read())
                {
                    return(false);
                }

                //sino se continua
                reader.Close();

                comand.CommandText =
                    "INSERT INTO DiasClase " +
                    "(fecha, idGrupo) " +
                    "VALUES(#" + dia.ToString("MM'/'dd'/'yy") + "#, " + idGrupo + " )";

                Console.WriteLine(comand.ExecuteNonQuery() + " Dia agregado");

                return(true);
            }
            finally
            {
                conection.Close();
                reader.Close();
            }
        }
コード例 #5
0
 public frm_NuevoProveedor(int id)
 {
     InitializeComponent();
     this.id = id;
     Mod     = true;
     btn_cancelar.Visible = false;
     groupBox2.Visible    = true;
     try
     {
         List <string>   aux          = new List <string>();
         OleDbDataReader DBdatareader = conexion.ConsultaDatos("SELECT * FROM Proveedores where Cod_Proveedor=" + id + ";");
         while (DBdatareader.Read())
         {
             aux.Add(DBdatareader[1].ToString());
             aux.Add(DBdatareader[2].ToString());
             aux.Add(DBdatareader[3].ToString());
             aux.Add(DBdatareader[4].ToString());
             aux.Add(DBdatareader[5].ToString());
             aux.Add(DBdatareader[6].ToString());
             aux.Add(DBdatareader[7].ToString());
             aux.Add(DBdatareader[8].ToString());
         }
         txt_nombre.Text    = aux[0];
         txt_cuit.Text      = aux[1];
         txt_Telefono.Text  = aux[3];
         txt_direccion.Text = aux[2];
         txt_Cuenta.Text    = aux[7];
         txt_ciudad.Text    = aux[6];
         txt_Email.Text     = aux[4];
         dateCompra.Text    = aux[5];
     }
     catch
     {
         MessageBox.Show("Error al cargar datos");
     }
 }
コード例 #6
0
            bool OpenDys(string pStrSQL, ref OleDbDataReader pDataReader)
            {
                OleDbCommand oleCommand;
                bool         vCheck = false;

                if (oleConn.State == ConnectionState.Open)
                {
                    try
                    {
                        oleCommand = new OleDbCommand(pStrSQL, oleConn);
                        oleCommand.CommandTimeout = 1;
                        pDataReader = oleCommand.ExecuteReader();
                        vCheck      = true;
                    }
                    catch (Exception exp)
                    {
                        Logfile logFile = new Logfile();
                        logFile.WriteErrLog("[ExecuteSQL]" + pStrSQL);
                        logFile.WriteErrLog("[ExecuteSQL]" + exp.Message);
                        logFile = null;
                    }
                }
                return(vCheck);
            }
コード例 #7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string          strConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("userchec.mdb");
        OleDbConnection objConnection = new OleDbConnection(strConnection); //建立连接

        objConnection.Open();

        /* string strConnection = "Server=.;database=USER; Integrated Security=SSPI;"; ;
         * conn = new SqlConnection(strConnection);
         *
         * conn.Open();*/
        string          sqlstr = "select* from user_infor where txtUserID='" + this.TextBox1.Text + "'";
        OleDbCommand    sqlcom = new OleDbCommand(sqlstr, objConnection);
        OleDbDataReader read   = sqlcom.ExecuteReader();

        read.Read();
        if (this.TextBox1.Text.Trim().Length == 0)
        {
            Response.Write("<script language='javascript'>alert('用户ID不得为空');</script>");
            return;
        }
        if (read.HasRows)
        {
            if (this.TextBox1.Text.Trim() == read["txtUserID"].ToString().Trim())
            {
                Response.Write("<script language='javascript'>alert('该用户ID已注册');</script>");
                return;
            }
        }
        else
        {
            Response.Write("<script language='javascript'>alert('该用户ID可用');</script>");
        }
        read.Close();
        conn.Close();
    }
コード例 #8
0
        private void FamilyForm_Load(object sender, EventArgs e)
        {
            PatientID.Text = Form2.selectedID;


            string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                                "Data Source=E:\\ITS245\\STEFPROJ\\Database11.accdb";

            OleDbConnection connection = new OleDbConnection(connString);
            OleDbCommand    cmd        = connection.CreateCommand();

            connection.Open();

            cmd.CommandText = "Select PtLastName, PtFirstname, DOB from Patienttable where PatientID=" + PatientID.Text;
            cmd.Connection  = connection;

            OleDbDataReader reader = cmd.ExecuteReader();

            reader.Read();
            Lname.Text = reader[0].ToString();
            Fname.Text = reader[1].ToString();
            AGE.Text   = reader[2].ToString();
            reader.Close();


            cmd.CommandText = "Select FamilyID from familyhistorytable where PatientID=" + PatientID.Text;
            OleDbDataReader reader2 = cmd.ExecuteReader();

            while (reader2.Read())
            {
                listBox1.Items.Add(reader2[0].ToString());
            }
            reader2.Close();

            connection.Close();
        }
コード例 #9
0
        private void buttonLesen_Click(object sender, EventArgs e)
        {
            con.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source = Zeiterfassung.accdb";
            cmd.Connection       = con;
            cmd.CommandText      = "SELECT u.ID, u.Benutzer, u.ErsterTag, u.LetzterTag, u.Art, f.ID, f.ErsterTag, f.LetzterTag FROM Freitage AS u, Feiertage AS f";

            listBoxFreitage.Items.Clear();
            listBoxFeiertage.Items.Clear();

            try
            {
                con.Open();

                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    listBoxFreitage.Items.Add(
                        reader["u.ID"] + "/" +
                        reader["Benutzer"] + "/" +
                        reader["u.ErsterTag"] + "/" +
                        reader["u.LetzterTag"] + "/" +
                        reader["Art"]);

                    listBoxFeiertage.Items.Add(
                        reader["f.ID"] + "/" +
                        reader["f.ErsterTag"] + "/" +
                        reader["f.LetzterTag"]);
                }
                reader.Close();
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #10
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //----------------------------------------------------
            string       sqlCmd_graph = "SELECT * FROM report_graph WHERE [Item]='" + try_lang + "'";
            OleDbCommand cmd_graph    = new OleDbCommand(sqlCmd_graph, con);

            try
            {
                con.Open();
                dr = cmd_graph.ExecuteReader();
                dr.Read();
                dr.Close();
                num_sl = dr.GetInt32(2);
                con.Close();
            }
            catch (Exception ex1)
            {
                con.Close();
            }
            num_sl -= 1;
            //-----------------------------------------------------
            string       sqlCmd2_5 = "UPDATE report_graph SET[Item]='" + try_lang + "',[No_ItemBought]=" + num_sl + " WHERE [Item]='" + try_lang + "'";
            OleDbCommand cmd2_5    = new OleDbCommand(sqlCmd2_5, con);

            try
            {
                con.Open();
                cmd2_5.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception ex2)
            {
                MessageBox.Show(ex2.Message);
                con.Close();
            }
        }
コード例 #11
0
        //fill the ComboBox Hochschule with Database
        private void AutoCompleteText_Land()
        {
            LandComboBox.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            LandComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
            AutoCompleteStringCollection coll = new AutoCompleteStringCollection();

            config = XmlDataManager.XmlConfigDataReader("configs.xml");
            string query = "SELECT txtName FROM tab_land";

            OleDbConnection UserConnection1 = new OleDbConnection
            {
                ConnectionString = config.DbConnectionString
            };

            try
            {
                UserConnection1.Open();
                OleDbCommand cmd1 = new OleDbCommand
                {
                    Connection  = UserConnection1,
                    CommandType = CommandType.Text,
                    CommandText = query
                };
                OleDbDataReader reader = cmd1.ExecuteReader();
                while (reader.Read())
                {
                    string LandName = reader["txtName"].ToString();
                    coll.Add(LandName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            LandComboBox.AutoCompleteCustomSource = coll;
        }
コード例 #12
0
        /// <summary>
        /// 转换实体
        /// </summary>
        /// <param name="read">OleDbDataReader</param>
        /// <returns>CategoryInfo</returns>
        private static List <CategoryInfo> DataReaderToListCate(OleDbDataReader read)
        {
            var list = new List <CategoryInfo>();

            while (read.Read())
            {
                var category = new CategoryInfo
                {
                    CategoryId  = Convert.ToInt32(read["categoryid"]),
                    ParentId    = Jqpress.Framework.Utils.TypeConverter.ObjectToInt(read["ParentId"], 0),
                    CateName    = Convert.ToString(read["CateName"]),
                    Slug        = Convert.ToString(read["Slug"]),
                    Description = Convert.ToString(read["Description"]),
                    SortNum     = Convert.ToInt32(read["SortNum"]),
                    PostCount   = Convert.ToInt32(read["PostCount"]),
                    CreateTime  = Convert.ToDateTime(read["CreateTime"])
                };
                //  category.Type = Convert.ToInt32(read["Type"]);

                list.Add(category);
            }
            read.Close();
            return(list);
        }
コード例 #13
0
        public Dictionary <string, int> GetSeatingChart()
        {
            //int x = 1;
            string fieldString = "";

            using (OleDbConnection conn = new OleDbConnection(connString))
            {
                try
                {
                    conn.Open();
                    OleDbDataReader reader  = null;
                    OleDbCommand    command = new OleDbCommand("SELECT * FROM crew WHERE id=@1", conn);
                    command.Parameters.AddWithValue("@1", crewNum);
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        for (int i = 1; i < 5; i++)
                        {
                            fieldString = "s" + i.ToString();
                            Seating.Add(fieldString + "A", (int)reader[fieldString + "A"]);
                            Seating.Add(fieldString + "B", (int)reader[fieldString + "B"]);
                            Seating.Add(fieldString + "C", (int)reader[fieldString + "C"]);
                            Seating.Add(fieldString + "D", (int)reader[fieldString + "D"]);
                        }

                        //Seating.Add("s1A", 0);
                        //firstSaw = ((int)reader["firstSaw"]) == 0 ? new InmateData() : new InmateData((int)reader["firstSaw"]);
                    }
                } catch (Exception ex)
                {
                    System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(ex.ToString(), "Getting Crew Information");
                    return(Seating);
                }
            }
            return(Seating);
        }
コード例 #14
0
ファイル: DataAccess.cs プロジェクト: lewistipping/The_Sound
    public static DataSet GetRandomSong()
    {
        OleDbConnection conn   = OpenConnection();
        Random          random = new Random((int)DateTime.Now.Ticks);

        String          getLastID = "SELECT TOP 1 TrackID FROM tblSong ORDER BY TrackID DESC";
        OleDbCommand    cmd       = new OleDbCommand(getLastID, conn);
        OleDbDataReader reader    = cmd.ExecuteReader();

        reader.Read();
        int lastID   = Convert.ToInt32(reader["TrackID"]);
        int randomID = random.Next(1, lastID);

        String strSQL = "SELECT TOP 1 TrackID, TrackTitle, TrackFilePath, tblAlbum.AlbumID, tblAlbum.AlbumTitle, tblAlbum.AlbumArtPath, "
                        + "tblArtist.ArtistID, tblArtist.ArtistName FROM (tblSONG INNER JOIN tblAlbum ON tblAlbum.AlbumID = tblSong.AlbumID) "
                        + "INNER JOIN tblArtist ON tblArtist.ArtistID = tblSong.ArtistID WHERE TrackID = " + randomID + ";";

        DataSet          randomSong    = new DataSet();
        OleDbDataAdapter randomAdapter = new OleDbDataAdapter(strSQL, conn);

        randomAdapter.Fill(randomSong, "randomSet");
        CloseConnection(conn);
        return(randomSong);
    }
コード例 #15
0
        /**
         *
         * 所有电表信息查询线程
         * 查询所有电表信息,并更新数据库
         *
         * */
        private void updateAllInfo_Tick(object sender, EventArgs e)
        {
            //byte[] Response = System.Text.Encoding.Default.GetBytes(Conmmend.GET_ALL_COLLECTER_INFO);//响应登录


            //获取所有网关ip与端口号
            DataOp dataOp = new DataOp(this.oracleip, this.oracleport, this.database, this.userid, this.password);

            //查询数据库中已注册的网关信息,找到其ip与端口,
            OleDbDataReader data = dataOp.GetAllRowByTable("GATEWAY_T");

            //遍历data,向网关发送数据包
            try
            {
                while (data.Read())
                {
                    string ip   = data[2].ToString();
                    string port = data[3].ToString();
                    string msg  = Conmmend.GET_ALL_COLLECTER_INFO;//查询所有电表信息

                    byte[] Msg = Encoding.UTF8.GetBytes(msg);

                    System.Net.IPAddress Ip = System.Net.IPAddress.Parse(ip);
                    int Port = int.Parse(port);

                    //Console.WriteLine("send to ip:" + ip + " port: " + port + " " + msg);
                    UDPSocket_serv.Send(Ip, Port, Msg);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ex : " + ex.Message);
            }

            dataOp.Close();
        }
コード例 #16
0
            int GetIndex()
            {
                if (!Forward)
                {
                    indexReader.Close();
                    indexReader = null;
                    da.SelectCommand.CommandText = string.Format(" select * from {0}:{0}"
                                                                 , rng.To.Row);
                }
                if (indexReader == null)
                {
                    indexReader = da.SelectCommand.ExecuteReader();
                }
                int cnt = 0;

                if (!indexReader.Read())
                {
                    return(-1);
                }
                for (int i = 0; i < indexReader.FieldCount; i++)
                {
                    if (!indexReader.IsDBNull(i))
                    {
                        cnt++;
                    }
                }
                return(cnt);
                //da.TableMappings.Clear();


                //da = new OleDbDataAdapter(da.SelectCommand.CommandText, eb.conn);
                //indexTable = new DataTable();
                ////da.FillSchema(indexTable, SchemaType.Source);
                //da.Fill(indexTable);
                //return indexTable.Columns.Count;
            }
コード例 #17
0
            void RunProcess()
            {
                while (!thrShutDown)
                {
                    oleConn = new OleDbConnection();
                    OleDbDataReader oleDataReader = null;
                    try
                    {
                        oleConn.ConnectionString = "Provider=OraOLEDB.Oracle;User ID=" + dbUser +
                                                   ";Password="******";Data Source=" + dbName + ";";
                        oleConn.Open();
                        string strSQL = "select t.config_data,t.update_date from tas.tas_config t where t.config_id=90"; //check database 1=master active
                        if (OpenDys(strSQL, ref oleDataReader))
                        {
                            if (oleDataReader.HasRows)
                            {
                                oleDataReader.Read();
                                _MasterDataBase = Convert.ToInt32(oleDataReader.GetString(0).ToString());
                                _UpdateDate     = oleDataReader.GetDateTime(1);

                                oleDataReader.Close();
                            }
                        }
                        else
                        {
                            _MasterDataBase = -1;
                        }
                        Thread.Sleep(3000);
                    }
                    catch (Exception exp)
                    {
                        _MasterDataBase = -1;
                    }
                    oleConn.Close();
                }
            }
コード例 #18
0
        }         //Saverate

        //Gets single conversion rate from the database
        public RateClass getSingleConversionRate(CurrencyClass ccFrom, CurrencyClass ccTo)
        {
            RateClass       rate          = null;
            string          CommandString = "Select * from CurrencyConverter where CurFromShort like '" + ccFrom.getShortName() + "' and CurToShort like '" + ccTo.getShortName() + "'";
            OleDbCommand    cmd           = new OleDbCommand(CommandString, MyConn);
            OleDbDataReader reader        = cmd.ExecuteReader();

            if (reader.RecordsAffected > 1)
            {
                //more then one record was returned
            }//endif
            else
            {
                double   rateVal   = 0;
                DateTime dateAdded = DateTime.Now;
                while (reader.Read())
                {
                    rateVal   = Convert.ToDouble(reader["Rate"].ToString());
                    dateAdded = Convert.ToDateTime(reader["DateTime"].ToString());
                } //emdwhile
                rate = new RateClass(ccFrom, ccTo, rateVal, dateAdded);
            }     //endelse
            return(rate);
        }         //getSingleConversionRate
コード例 #19
0
    public void Test()
    {
        using (OleDbConnection connection = new OleDbConnection(
                   "Provider=MSDataShape;Data Provider=SQLOLEDB;" +
                   "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind"))
        {
            OleDbCommand customerCommand = new OleDbCommand(
                "SHAPE {SELECT CustomerID, CompanyName FROM Customers} " +
                "APPEND ({SELECT CustomerID, OrderID FROM Orders} AS CustomerOrders " +
                "RELATE CustomerID TO CustomerID)", connection);
            connection.Open();

            OleDbDataReader customerReader = customerCommand.ExecuteReader();

            // This access should be tainted.
            while (customerReader.Read())
            {
                // This access should be tainted.
                Console.WriteLine("Orders for " + customerReader.GetString(1));
                Console.WriteLine("Orders for " + customerReader["foo"]);
            }
            customerReader.Close();
        }
    }
コード例 #20
0
        private void ReadIntrastatDefault()
        { OleDbConnection dbConn = new OleDbConnection(_oleDBConnectionString);
            OleDbCommand dbCommand = null;
            OleDbDataReader dbReader = null;
            string dbQuery = string.Empty;
            try
            {
                dbConn.Open();
                dbQuery = "SELECT * FROM Intrastat_Default WHERE Cod_Fiscal='" + Firma.CodFiscal + "'";
                dbCommand = new OleDbCommand(dbQuery, dbConn);
                dbReader = dbCommand.ExecuteReader();
                if (dbReader.HasRows)
                {
                    while (dbReader.Read())
                    {
                        Val_Implicite.I_Incoterms = dbReader["I_Incoterms"].ToString();
                        Val_Implicite.I_Mod_Transp = dbReader["I_Mod_Transp"].ToString();
                        Val_Implicite.I_Nat_Transp = dbReader["I_Nat_Tranz"].ToString();
                        Val_Implicite.I_Tara_Exp = dbReader["I_Tara_Exp"].ToString();
                        Val_Implicite.O_Incoterms = dbReader["O_Incoterms"].ToString();
                        Val_Implicite.O_Mod_Transp = dbReader["O_Mod_Transp"].ToString();
                        Val_Implicite.O_Nat_Tranz = dbReader["O_Nat_Tranz"].ToString();
                        Val_Implicite.O_Tara_Dest = dbReader["O_Tara_Dest"].ToString();

                        //_cmbAchizitiiCondLivrare.Add(new DateSetariImplicite { Cod = dbReader["Incoterms_COD"].ToString(), Denumire = dbReader["Incoterms_DESC"].ToString() });
                        //_cmbLivrariCondLivrare.Add(new DateSetariImplicite { Cod = dbReader["Incoterms_COD"].ToString(), Denumire = dbReader["Incoterms_DESC"].ToString() });
                    }
                }
                dbConn.Close();
                
            }
            catch (Exception exp)
            {
                MessageBox.Show("Eroare: " + exp.Message);
            }
        }
コード例 #21
0
        /// <summary> array de calificaciones de los proyectos presentados por el alumno indicado </summary>
        internal static int[] getCalifProy(int idAlumno, Proyecto[] listProyectoss)
        {
            List <int> calificaciones = new List <int>();

            try
            {
                conection.Open();

                foreach (Proyecto proy in listProyectoss)
                {
                    comand.CommandText =
                        "SELECT * FROM Entregas " +
                        "WHERE alumno =" + idAlumno +
                        "AND entregable = " + proy.id;

                    reader = comand.ExecuteReader();

                    if (reader.Read())
                    {
                        calificaciones.Add((int)reader["calif"]);
                    }
                    else
                    {
                        calificaciones.Add(50);
                    }

                    reader.Close();
                }
            }
            finally
            {
                reader.Close();
                conection.Close();
            }
            return(calificaciones.ToArray());
        }
コード例 #22
0
        private void btn_buscar_Click(object sender, EventArgs e)
        {
            string cadena = "Select * from ProductoTB where Producto ='" + combProductos.Text + "' ";

            OleDbConnection cnn     = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=PuntodeVentaBD.accdb");
            OleDbCommand    comando = new OleDbCommand(cadena, cnn);

            cnn.Open();

            OleDbDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)
            {
                //MessageBox.Show("El registro se a encontrado");

                txt_producto.Text    = leer["Producto"].ToString();
                txt_descripcion.Text = leer["Descripcion"].ToString();
                txt_cantidad.Text    = leer["Cantidad"].ToString();
                txt_precio.Text      = leer["Precio"].ToString();
                lbl_cont.Text        = leer["Id"].ToString();


                //comInfo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                //comInfo.AutoCompleteSource = AutoCompleteSource.ListItems;
            }
            else
            {
                //MessageBox.Show("No se encontro");

                txt_producto.Text    = "";
                txt_descripcion.Text = "";
                txt_cantidad.Text    = "";
                txt_precio.Text      = "";
            }
            cnn.Close();
        }
コード例 #23
0
ファイル: Login.cs プロジェクト: Milixk/shoesrus
        //Check the user email and password on the system and return a true or false customer ID
        public int loggingIn(string email, string password)
        {
            int customerID = -999;

            OleDbConnection dbCon = new OleDbConnection(DatabaseConnection.dbconnect);

            dbCon.ConnectionString = DatabaseConnection.dbconnect;
            OleDbCommand dbCmd = dbCon.CreateCommand();

            dbCmd.CommandText = "SELECT CustomerID FROM Customer WHERE CustomerEmail = @CustomerEmail AND CustomerPassword = @CustomerPassword";
            dbCmd.Parameters.AddWithValue("CustomerEmail", email);
            dbCmd.Parameters.AddWithValue("CustomerPassword", password);

            dbCon.Open();
            OleDbDataReader reader = dbCmd.ExecuteReader();

            while (reader.Read())
            {
                customerID = Convert.ToInt32(reader[0]);
            }
            reader.Close();

            return(customerID);
        }
コード例 #24
0
        private bool penguranganBarang(String kodeJual)
        {
            bool res = false;

            try
            {
                conn.Open();
                String       query = "SELECT * FROM barang WHERE kode_jual = '" + kodeJual + "'";
                OleDbCommand cmd   = new OleDbCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = query;
                cmd.Connection  = conn;

                OleDbDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        res = true;
                    }
                }
                else
                {
                    MessageBox.Show("Barang tidak ditemukan!", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    res = false;
                }
                reader.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                res = false;
            }
            return(res);
        }
コード例 #25
0
ファイル: Form3.cs プロジェクト: tugsadocal8/TBSRO
        private void Sefer()
        {
            string nereden = comboBoxNereden.SelectedText;
            string nereye  = comboBoxNereye.SelectedText;

            baglantı.Open();
            OleDbCommand    da   = new OleDbCommand("SELECT GidisTarihi FROM SeferBilgileri1 WHERE Nereden='" + comboBoxNereden.Text + "' and Nereye ='" + comboBoxNereye.Text + "' ", baglantı);
            OleDbDataReader oku1 = null;

            oku1 = da.ExecuteReader();
            while (oku1.Read())
            {
                ListViewItem ekle = new ListViewItem();
                ekle.Text = oku1["GidisTarihi"].ToString();
                listView1.Items.Add(ekle);
            }

            if (listView1.Items[0].Text == dateTimeGidis.Value.ToString("dddd"))
            {
                Form4 yeni4 = new Form4();

                yeni4.ShowDialog();
            }
            if (listView1.Items[1].Text == dateTimeGidis.Value.ToString("dddd"))
            {
                Form4 yeni4 = new Form4();

                yeni4.ShowDialog();
            }
            else
            {
                MessageBox.Show("Sefer bulunamadı.");
            }

            baglantı.Close();
        }
コード例 #26
0
 public LotteryDrawResult GetLatestDrawResult(int gameCd)
 {
     using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
         using (OleDbCommand command = new OleDbCommand())
         {
             command.CommandType = CommandType.Text;
             command.CommandText = " SELECT TOP 1 * " +
                                   "   FROM `draw_results` " +
                                   "  WHERE `game_cd`= @game_cd " +
                                   "  ORDER BY `draw_date` DESC";
             command.Parameters.AddWithValue("@game_cd", gameCd.ToString());
             command.Connection = conn;
             conn.Open();
             using (OleDbDataReader reader = command.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     return(GetLotteryDrawResultSetup(reader,
                                                      ClassReflectionUtil.FindGameMode(int.Parse(reader["game_cd"].ToString()))));
                 }
             }
         }
     return(null);;
 }
コード例 #27
0
        public ActionResult EditService(string ServiceId)
        {
            Models.Service servicio = new Models.Service();

            try
            {
                OleDbConnection cn = new OleDbConnection(cadena);
                cn.Open();

                int userId = Convert.ToInt32(Session["UserSession"]);
                //int userId = 1;
                string query = string.Format("SELECT Descripcion, Id_Servicio FROM Servicios WHERE Id_Servicio = {0}", ServiceId);

                OleDbCommand    cmd    = new OleDbCommand(query, cn);
                OleDbDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    servicio.Descripcion = reader["Descripcion"].ToString();
                    servicio.id_servicio = Convert.ToInt32(ServiceId);
                }
                else
                {
                    ViewData["Error"] = "El servicio que se quizo editar no existe o no es permitido!";
                    return(RedirectToAction("Index"));
                }

                cn.Close();
            }
            catch (Exception ex)
            {
            }

            return(View(servicio));
        }
コード例 #28
0
        public List <int> GetTopDrawnDigitFromDateRange(GameMode gameMode, DateTime dateFrom, DateTime dateTo)
        {
            List <int> merge = new List <int>();

            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = "SELECT num1, num2, num3, num4, num5, num6 " +
                                          "  FROM draw_results " +
                                          "  WHERE game_cd = @game_cd " +
                                          "    AND draw_date BETWEEN CDATE(@dateFrom) AND CDATE(@dateTo)";
                    command.Parameters.AddWithValue("@game_cd", (int)gameMode);
                    command.Parameters.AddWithValue("@dateFrom", dateFrom.Date.ToString());
                    command.Parameters.AddWithValue("@dateTo", dateTo.Date.ToString());
                    command.Connection = conn;
                    conn.Open();

                    using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                merge.Add(int.Parse(reader["num1"].ToString()));
                                merge.Add(int.Parse(reader["num2"].ToString()));
                                merge.Add(int.Parse(reader["num3"].ToString()));
                                merge.Add(int.Parse(reader["num4"].ToString()));
                                merge.Add(int.Parse(reader["num5"].ToString()));
                                merge.Add(int.Parse(reader["num6"].ToString()));
                            }
                        }
                    }
                }
            return(merge);
        }
コード例 #29
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            String book = "";

            MessageBox.Show("mk");
            for (int ix = 0; ix < CheckBoxList2.Items.Count; ++ix)
            {
                if (CheckBoxList2.Items[ix].Selected == true)
                {
                    MessageBox.Show(CheckBoxList2.Items[ix].ToString());
                    book = CheckBoxList2.Items[ix].ToString();
                }
            }

            OleDbConnection con = new OleDbConnection();

            con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;"
                                   + "Data Source=C:\\Users\\Intag\\Documents\\GitHub\\Lab2new\\lms\\lms\\App_Data\\Database1.accdb";
            con.Open();
            string       selectString = "select Distinct Artifacts.ISBN,Title,Author,Publication,Genre,Type from Artifacts,a Where a.Status='" + "available' and Artifacts.Title='" + book + "'";
            OleDbCommand cmd          = new OleDbCommand(selectString, con);

            cmd.Parameters.AddWithValue("@TextS", DropDownList1.SelectedItem.Text);
            cmd.Parameters.AddWithValue("@Text", TextBox1.Text);
            cmd.Connection = con;
            OleDbDataReader dr = cmd.ExecuteReader();


            while (dr.Read())
            {
                bname = dr[1].ToString();
                b_id  = dr[0].ToString();
            }

            Response.Redirect("Issue.aspx?bID" + b_id + "&bName=" + bname);
        }
コード例 #30
0
        private void FillLegendaryWeaponsList()
        {
            lstLegendaries.Items.Clear();

            //Pull the names from the database and fill the list
            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                //Query the WeaponsLegendary table for a list of all legendary weapons
                string weaponsLegendaryQuery = "SELECT * FROM WeaponsLegendary WHERE "
                    + "Type = '" + cboType.SelectedItem + "';";

                OleDbCommand command = new OleDbCommand(weaponsLegendaryQuery, connection);

                try
                {
                    connection.Open();
                    OleDbDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        //Add the legendary wepaon Name and Special Stat description to the list box
                        lstLegendaries.Items.Add(reader[1].ToString() + " | " + reader[9].ToString().Replace("/r/n", " | "));
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    connection.Close();
                }

                Console.ReadLine();
            }
        }