当前位置: 首页>>代码示例>>C#>>正文


C# OleDbCommand.ExecuteReader方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbCommand.ExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbCommand.ExecuteReader方法的具体用法?C# OleDbCommand.ExecuteReader怎么用?C# OleDbCommand.ExecuteReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbCommand的用法示例。


在下文中一共展示了OleDbCommand.ExecuteReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: lc

        private void lc(object sender, MouseEventArgs e)
        {
            c.Open();
            DataSet ds = new DataSet();
            string query = "select ID,pname,bill,pbill from pdetails where [email protected] ";
            OleDbCommand cmd = new OleDbCommand(query, c);
            cmd.Parameters.Add("@bc", OleDbType.Date).Value = dateTimePicker1.Value.Date;
            OleDbDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            /*ds.Tables.Add(dt);
            OleDbDataAdapter da = new OleDbDataAdapter();
            da.Fill(dt);*/
            dataGridView1.DataSource = dt.DefaultView;
            c.Close();
            try
            {
                c.Open();
                String str = @"SELECT SUM(pbill) FROM pdetails WHERE date[email protected];";

                OleDbCommand comm2 = new OleDbCommand(str, c);
                comm2.Parameters.Add("@bb", OleDbType.Date).Value = dateTimePicker1.Value.Date;
                bill = Convert.ToDouble(comm2.ExecuteScalar());

                label3.Text = bill.ToString() + "/-";
            }
            catch(Exception ex)
            {
                MessageBox.Show("selected date miss match");
                c.Close();
            }
                c.Close();
        }
开发者ID:sankeerthsaan18,项目名称:Dignostic,代码行数:33,代码来源:Form5.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            string sql = "";
         string connstring [email protected]"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DropBox\My Dropbox\Devry\CIS407\SU10B\day8\mobileweb1\NorthWind.mdb;";
            System.Data.OleDb.OleDbDataReader dr;
            System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();

            //get this from connectionstrings.com/access
            conn.ConnectionString = connstring;
            conn.Open();
            //here I can talk to my db...
            comm.Connection = conn;

            //Console.WriteLine(conn.State);
            sql = "select categoryid, categoryname from categories";
            comm.CommandText = sql;
            dr = comm.ExecuteReader();
            rptCategory.DataSource = dr;
            rptCategory.DataBind();
            dr.Close();
            //Console.WriteLine(conn.State);
            sql = "select supplierid, companyname from suppliers";
            comm.CommandText = sql;
            dr = comm.ExecuteReader();
            rptSupplier.DataSource = dr;
            rptSupplier.DataBind();
    }
开发者ID:jasonhuber,项目名称:2010Fall_CIS407,代码行数:28,代码来源:Default.aspx.cs

示例3: LoadData

    protected void LoadData()
    {
        string strsql = "select * from customers where custnumber = " + Session["custid"];
        OleDbConnection myConn = new OleDbConnection();
        myConn.ConnectionString = System.Web.Configuration.WebConfigurationManager.
        ConnectionStrings["AcmeShoppeConnectionString"].ConnectionString;
        OleDbCommand myCmd = new OleDbCommand(strsql, myConn);
        OleDbDataReader myReader;
        if (myConn.State == ConnectionState.Closed) myConn.Open();
            myReader = myCmd.ExecuteReader();

            if (myReader.HasRows)
            {
                myReader.Read();
                this.lblFName.Text = myReader["FirstName"].ToString();
                this.lblLName.Text = myReader["LastName"].ToString();
                this.txtAddress.Text = myReader["Address"].ToString();
                this.txtCity.Text = myReader["City"].ToString();
                this.txtZip.Text = myReader["ZipCode"].ToString();
                this.DropDownList1.SelectedValue = myReader["State"].ToString();
            }
            else
                this.lblerr.Text = "error";
         myReader.Close();
         myCmd.CommandText = "select sum(extension) from cart_view01 " +
                                    "where cartnumber = " + Session["cartnumber"];
         decimal decSubtotal = 0;
         double decSalesTax = 0;
         double decTotal = 0;
         double decShip = 3.25;
         if (myConn.State == ConnectionState.Closed) myConn.Open();
         myReader = myCmd.ExecuteReader();
         if (myReader.HasRows)
         {
             myReader.Read();
             if (myReader[0] != DBNull.Value)
             {
                 decSubtotal = Convert.ToDecimal(myReader[0].ToString());
                 this.lblSubtotal.Text = decSubtotal.ToString("c");
             }
             decSalesTax = Convert.ToDouble(decSubtotal) * .05;
             Math.Round(decSalesTax, 2);
             decTotal = Convert.ToDouble(decSubtotal) + decSalesTax + decShip;
             Math.Round(decTotal, 2);
             this.lblTax.Text = decSalesTax.ToString("c");
             this.lblTotal.Text = decTotal.ToString("c");
             this.lblShipping.Text = decShip.ToString("c");
         }
         else
             this.lblerr.Text = "error";
         myConn.Close();
    }
开发者ID:aruntosa,项目名称:Client-Server-Final-Project-C-Sharp,代码行数:52,代码来源:Checkout.aspx.cs

示例4: Guncelle

        private void Guncelle()
        {
            using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=hesap.mdb"))
            {
                conn.Open();
                OleDbCommand komut = new OleDbCommand();
                komut.Connection = conn;
                komut.CommandText = "Select * from hesap"; // sorgu / komut cumlemi yazıyorum.
                komut.ExecuteNonQuery(); // insert , updateiçin gerekli satir sayisi donduruyoruz.
                OleDbDataReader dr = komut.ExecuteReader(); // datareader olusturup komut sorgulayıp veritabaninda okuma işlemini tanıtıyoruz
                while (dr.Read()) // datareader ile okuyoruz.
                {
                    string hadi = dr["hadi"].ToString();
                    string kadi = dr["kadi"].ToString();
                    string q;
                    using (WebClient asd = new WebClient())
                    {
                        asd.Encoding = Encoding.UTF8;
                        q = asd.DownloadString("http://gdata.youtube.com/feeds/api/users/" + kadi + "/uploads?v=2&alt=jsonc&max-results=0");
                    }
                    string[] adet1 = q.Split(new string[] { "totalItems\":" }, StringSplitOptions.None);
                    string[] adet2 = adet1[1].Split(',');
                    listView1.Items.Add(new ListViewItem(new string[] { hadi, "Adet: "+adet2[0] }));
                }
                dr.Close();
                komut.ExecuteNonQuery(); // insert , updateiçin gerekli satir sayisi donduruyoruz.
                dr = komut.ExecuteReader(); // datareader olusturup komut sorgulayıp veritabaninda okuma işlemini tanıtıyoruz
                while (dr.Read()) // datareader ile okuyoruz.
                {
                    string kadi = dr["hadi"].ToString(); // veritabanimdaki "kadi" alanımdaki veriyi alip kadi değişkenine atıyorum(yukarıda string olusturmustum)
                    string sifre = dr["hsifresi"].ToString(); // aynı durum söz konusu
                    string devkey = dr["devkey"].ToString();
                    Random a = new Random();
                    string id = a.Next(100000, 999999).ToString();
                    YouTubeRequestSettings settings = new YouTubeRequestSettings(id, devkey, kadi,sifre);
                    YouTubeRequest request = new YouTubeRequest(settings);

                    string feedUrl = "https://gdata.youtube.com/feeds/api/users/default/uploads";

                    Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));
                    foreach (Video entry in videoFeed.Entries)
                    {
                        string vid_thumb ="http://img.youtube.com/vi/"+entry.VideoId+"/0.jpg";
                        int izlenme = entry.ViewCount;
                        if(izlenme == -1)
                            izlenme = 0;
                        listView1.Items.Add(new ListViewItem(new string[] { kadi,entry.YouTubeEntry.Title.Text,izlenme.ToString()  }));
                    }
                }
            }
        }
开发者ID:voyl,项目名称:myprojects,代码行数:51,代码来源:Form1.cs

示例5: btnLogin_Click

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string strsql = "select [CustNumber], [Email], [PWD] from customers";
        OleDbConnection myConn = new OleDbConnection();
        myConn.ConnectionString = System.Web.Configuration.WebConfigurationManager.
        ConnectionStrings["AcmeShoppeConnectionString"].ConnectionString;
        OleDbCommand myCmd = new OleDbCommand(strsql, myConn);
        OleDbDataReader myReader;
        if (myConn.State == ConnectionState.Closed) myConn.Open();
            myReader = myCmd.ExecuteReader();
            DataTable dataTable = new DataTable();
            dataTable.Load(myReader);
            int rowCount = rowCount = dataTable.Rows.Count;
            myReader = myCmd.ExecuteReader();

            int i = 0;

            if (myReader.HasRows)
            {

                while (i < rowCount)
                {
                    myReader.Read();

                    string strId = this.txtUser.Text;
                    string strPwd = this.txtPass.Text;
                    string memId = myReader["Email"].ToString();
                    string memPwd = myReader["PWD"].ToString();
                    if (strId == memId && strPwd == memPwd)
                    {
                        FormsAuthentication.RedirectFromLoginPage(strId, false, strPwd);
                        string custid = myReader["CustNumber"].ToString();
                        Session["custid"] = custid;
                        Session["userid"] = memId;
                        break;

                    }
                    else if (strId == "admin" && strPwd == "admin")
                    {
                        FormsAuthentication.RedirectFromLoginPage(strId, false, strPwd);
                        break;
                    }

                    i++;
                }
                if (i == rowCount)
                        this.lblmessage.Text = "User Does not exist!";
            }
    }
开发者ID:aruntosa,项目名称:Client-Server-Final-Project-C-Sharp,代码行数:49,代码来源:Login.aspx.cs

示例6: GetStatistics

        public static Dictionary<string, Dictionary<string, object>> GetStatistics()
        {
            Dictionary<string, Dictionary<string, object>> list = new Dictionary<string, Dictionary<string, object>>();

            string strConnection = "provider=Microsoft.ACE.OLEDB.12.0;Data Source=Battleship.accdb;";
            string strSQL = "";
            OleDbConnection myConnection = new OleDbConnection(strConnection);
            OleDbCommand myCommand = new OleDbCommand(strSQL, myConnection);
            try
            {
                myConnection.Open();
                strSQL = "SELECT Name, Min(Turns), Count(*) FROM Statistic WHERE IsWinner GROUP BY Name ORDER BY Name";
                myCommand.CommandText = strSQL;
                myCommand.CommandType = System.Data.CommandType.Text;
                OleDbDataReader reader = myCommand.ExecuteReader();
                while (reader.Read())
                {
                    Dictionary<string, object> fields = new Dictionary<string, object>();
                    fields["Turns"] = reader.GetInt32(1).ToString();
                    fields["Wins"] = reader.GetInt32(2).ToString();
                    fields["Loses"] = 0;
                    list[reader.GetString(0)] = fields;
                }
                reader.Close();

                strSQL = "SELECT Name, Count(*) FROM Statistic WHERE NOT IsWinner GROUP BY Name ORDER BY Name";
                myCommand.CommandText = strSQL;
                myCommand.CommandType = System.Data.CommandType.Text;
                reader = myCommand.ExecuteReader();
                while (reader.Read())
                {
                    if (!list.ContainsKey(reader.GetString(0)))
                    {
                        Dictionary<string, object> fields = new Dictionary<string, object>();
                        fields["Turns"] = "DNA";
                        fields["Wins"] = 0;
                        list[reader.GetString(0)] = fields;
                    }
                    list[reader.GetString(0)]["Loses"] = reader.GetInt32(1).ToString();
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
            myConnection.Close();
            return list;
        }
开发者ID:baskinbrent,项目名称:battleship,代码行数:49,代码来源:Database.cs

示例7: ReadFile

        /// <summary>
        /// Reads the selected file and places the contents into a DataTable.
        /// </summary>
        /// <returns>Datatable of students in file</returns>
        public DataTable ReadFile()
        {
            DataTable data = new DataTable();

            try
            {
                using (cmd = con.CreateCommand())
                {
                    cmd.CommandText = string.Format("SELECT * from [{0}]", file.Name);
                    con.Open();

                    using (dr = cmd.ExecuteReader())
                    {
                        data.Load(dr);
                    }
                }
            }
            catch (OleDbException oExe)
            {
                Debug.WriteLine(oExe.Message);
            }
            finally
            {
                con.Close();
            }

            return data;
        }
开发者ID:JRDuenow,项目名称:ProgressBuilder,代码行数:32,代码来源:Reader.cs

示例8: datefilterPlanMeal_DayRender

        protected void datefilterPlanMeal_DayRender(object sender, DayRenderEventArgs e)
        {
            OleDbCommand command = new OleDbCommand("SELECT * FROM PlannedMeal WHERE UserDataID = " + userID + " ORDER BY CreatedDate DESC", myConnection);

            OleDbDataReader dr = command.ExecuteReader();
            // Read DataReader till it reaches the end
            while (dr.Read() == true)
            {
                // Assign the Calendar control dates
                // already contained in the database
                //datefilterPlanMeal.SelectedDates.Add((DateTime)dr["CreatedDate"]);
                if (e.Day.Date == (DateTime)dr["CreatedDate"])
                {
                    e.Cell.BackColor = System.Drawing.Color.Silver;
                }
            }
            if (e.Day.IsSelected)
            {
                e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml("#4db6ac");
                e.Cell.ForeColor = System.Drawing.Color.White;
            }

            // Close DataReader
            dr.Close();
        }
开发者ID:trinhphandinhhuy,项目名称:FoodApp,代码行数:25,代码来源:PlannedMealHistory.aspx.cs

示例9: fill_form

 private void fill_form(string p_id)
 {
     String strQuery = String.Empty;
     OleDbConnection sqlConn = new OleDbConnection();
     OleDbCommand sqlComm = new OleDbCommand();
     OleDbDataReader sqlRead;// = new OleDbDataReader();
     DateTime strReturn = DateTime.Now;
     //
     sqlConn.ConnectionString = PCPUB.m_oledb_connection.ToString();
     sqlConn.Open();
     //
     strQuery = String.Empty;
     strQuery += " SELECT";
     strQuery += " [yarn_count_id],";
     strQuery += " [yarn_count_name]";
     strQuery += " FROM [tis_yarn_count]";
     strQuery += " WHERE [yarn_count_id] = '" + p_id + "'";
     //
     sqlComm.Connection = sqlConn;
     sqlComm.CommandText = strQuery.ToString();
     sqlRead = sqlComm.ExecuteReader();
     //
     if (sqlRead.Read())
     {
         txt_yarn_count_id.Text = sqlRead["yarn_count_id"].ToString();
         txt_yarn_count_name.Text = sqlRead["yarn_count_name"].ToString();
     }
     //
     sqlRead.Close();
     sqlConn.Close();
     sqlRead.Dispose();
     sqlComm.Dispose();
     sqlConn.Dispose();
 }
开发者ID:balasmani,项目名称:texpro,代码行数:34,代码来源:FMAD104.cs

示例10: sepetcevir

        public DataTable sepetcevir(string uyeID, string map)
        {

            OleDbConnection cnn = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" + map);
            cnn.Open();
            OleDbCommand cmd = new OleDbCommand("select sepet from uyeler where uyeid=" + uyeID, cnn);
            OleDbDataReader rdr = cmd.ExecuteReader();
            rdr.Read();
            string[] urunler = rdr[0].ToString().Split(',');

            DataTable dt = new DataTable();
            dt.Columns.AddRange(new DataColumn[3] { new DataColumn("fid"), new DataColumn("aciklama"), new DataColumn("fiyat") });

            if (rdr[0].ToString() != "")
            {
                foreach (string item in urunler)
                {
                    cmd.Dispose();
                    string fid = item;

                    cmd = new OleDbCommand("select * from fotolar where fot_id=" + fid, cnn);
                    OleDbDataReader rdr2 = cmd.ExecuteReader();
                    rdr2.Read();
                    string ack = rdr2[5].ToString();
                    string fiyat = rdr2[6].ToString();

                    dt.Rows.Add(fid, ack, fiyat);
                }
            }

            cnn.Close();

            return dt;
        }
开发者ID:dgncn,项目名称:fotosale,代码行数:34,代码来源:urunler.cs

示例11: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        int lgflg = 0;

        OleDbConnection conn = new OleDbConnection(ConfigurationSettings.AppSettings["classDB"]);
        OleDbCommand cmd = new OleDbCommand("SELECT * FROM student WHERE studentpassword = '" + password.Text + "' AND email = '" + userName.Text + "'", conn);

        conn.Open();
        OleDbDataReader myReader = cmd.ExecuteReader();

        while (myReader.Read())
        {
            lgflg = 1;
            Session.Add("fname", myReader["Contact_name"]);
            Session.Add("address", myReader["address"]);
            Session.Add("city", myReader["city"]);
            Session.Add("state", myReader["state"]);
            Session.Add("zipcode", myReader["zipcode"]);
        }
        myReader.Close();
        conn.Close();

        if (lgflg == 1)
        {
            Response.Write(Session["fname"]);
        }
        else
        {
            error.Visible = true;
        }
    }
开发者ID:KungfuCreatives,项目名称:P3WebApp,代码行数:31,代码来源:Login.aspx.cs

示例12: Window_jianzhan4

 public Window_jianzhan4()
 {
     InitializeComponent();
     systime.Content = DateTime.Now.ToShortTimeString();
     OleDbDataReader dr;
     OleDbConnection conn = new OleDbConnection(odbcConnStr);
     string sql = "select * from rearview_checking";
     OleDbCommand cmd = new OleDbCommand(sql, conn);
     conn.Open();
     dr = cmd.ExecuteReader();
     if (dr.Read())
     {
         string s;
         double t,k;
         station_point.Content = dr.GetString(1).ToString();
         rearview_point.Content = dr.GetString(2).ToString();
         BS.Content = dr.GetString(3).ToString();
         s = BS.Content.ToString();
         t = Convert.ToDouble(s);
         Random ran = new Random();
         k = ran.Next(0, 200)*0.0001;
         t = k + t;
         HA.Content = t.ToString();
         dHA.Content = k.ToString();
     }
     conn.Close();                    
 }
开发者ID:Simulatio-of-Quanzhanyi,项目名称:moniquanzhanyi,代码行数:27,代码来源:Window_jianzhan4_HouShiJc.xaml.cs

示例13: DatatypeQuery

        //---------------------------------------------------------------------
        public static void DatatypeQuery(OleDbConnection dbcon, CodeGenerator cg)
        {
            cg.DataTypeList.Clear();
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM DataTypes", dbcon);
            OleDbDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                DataType curDatatype = new DataType();

                curDatatype.ID = Convert.ToInt32(dr["ID"].ToString());
                curDatatype.DataTypeName = dr["DataTypeName"].ToString();
                curDatatype.CType = dr["CType"].ToString();
                curDatatype.CTypeDef = dr["CTypeDef"].ToString();

                curDatatype.CSType = dr["CSType"].ToString();
                curDatatype.CSTypeDef = dr["CSTypeDef"].ToString();

                curDatatype.VBType = dr["VBType"].ToString();
                curDatatype.VBTypeDef = dr["VBTypeDef"].ToString();

                curDatatype.PythonType = dr["PythonType"].ToString();
                curDatatype.PythonTypeDef = dr["PythonTypeDef"].ToString();

                cg.DataTypeList.Add(curDatatype);
            }

            dr.Close();
        }
开发者ID:kevinflueckiger,项目名称:Application-SDK,代码行数:30,代码来源:DBReader.cs

示例14: ConstantQuery

        //---------------------------------------------------------------------
        public static void ConstantQuery(OleDbConnection dbcon, CodeGenerator cg)
        {
            cg.ConstantList.Clear();
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM Constants ORDER BY Topic, ID", dbcon);
            OleDbDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Constant curConst = new Constant();
                curConst.Name = dr["Name"].ToString();
                curConst.Value = dr["Value"].ToString();
                Int32 nTopic = Convert.ToInt32(dr["Topic"].ToString());
                if (nTopic > 0)
                {
                    curConst.Topic = cg.TopicList[nTopic - 1].Name.ToString();
                }
                else
                {
                    curConst.Topic = "";
                }
                curConst.Description = dr["Description"].ToString();
                cg.ConstantList.Add(curConst);

                //curConst.Print();
            }

            dr.Close();
        }
开发者ID:kevinflueckiger,项目名称:Application-SDK,代码行数:29,代码来源:DBReader.cs

示例15: Roles_CreateRole

		public static int Roles_CreateRole (DbConnection connection, string applicationName, string rolename)
		{
			string appId = (string) DerbyApplicationsHelper.Applications_CreateApplication (connection, applicationName);
			if (appId == null)
				return 1;

			string querySelect = "SELECT RoleName FROM aspnet_Roles WHERE ApplicationId = ? AND LoweredRoleName = ?";
			OleDbCommand cmdSelect = new OleDbCommand (querySelect, (OleDbConnection) connection);
			AddParameter (cmdSelect, "ApplicationId", appId);
			AddParameter (cmdSelect, "LoweredRoleName", rolename.ToLowerInvariant ());

			using (OleDbDataReader reader = cmdSelect.ExecuteReader ()) {
				if (reader.Read ())
					return 2; // role already exists
			}

			string queryInsert = "INSERT INTO aspnet_Roles (ApplicationId, RoleId, RoleName, LoweredRoleName) VALUES (?, ?, ?, ?)";
			OleDbCommand cmdInsert = new OleDbCommand (queryInsert, (OleDbConnection) connection);
			AddParameter (cmdInsert, "ApplicationId", appId);
			AddParameter (cmdInsert, "RoleId", Guid.NewGuid ().ToString ());
			AddParameter (cmdInsert, "RoleName", rolename);
			AddParameter (cmdInsert, "LoweredRoleName", rolename.ToLowerInvariant ());
			cmdInsert.ExecuteNonQuery ();

			return 0;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:26,代码来源:DerbyRolesHelper.cs


注:本文中的System.Data.OleDb.OleDbCommand.ExecuteReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。