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


C# OleDbCommand.Close方法代码示例

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


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

示例1: ImportDataFromExcelEquity

        public void ImportDataFromExcelEquity()
        {

            string excelFilePath = "C:/Users/ahksysuser06/Desktop/EDISData/International_Equity_Daily_Closing_Price_20131211.xlsx";
            // make sure your sheet name is correct, here sheet name is sheet1, so you can change the sheet name if have    different 
            string excelQuery = "select SecId,Name,Symbol from [Sheet1$]";
            try
            {
                string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFilePath +
                ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;'";
                OleDbConnection oleConn = new OleDbConnection(excelConnectionString);
                oleConn.Open();
                OleDbDataReader oleReader = new OleDbCommand(excelQuery, oleConn).ExecuteReader();
                //while (oleReader.Read())
                //{
                //    Domain.Portfolio.AggregateRoots.Asset.Equity equity = new AustralianEquity(edisRepo)
                //    {
                //        Name = oleReader.GetString(1),
                //        Sector = oleReader.GetString(0),
                //        Ticker = oleReader.GetString(2),
                //        EquityType = EquityTypes.AustralianEquity,
                //    };

                //    edisRepo.InsertEquityData(equity);
                //}
                while (oleReader.Read())
                {
                    Domain.Portfolio.AggregateRoots.Asset.Equity equity = new InternationalEquity(edisRepo)
                    {
                        Name = oleReader.GetString(1),
                        Sector = oleReader.GetString(0),
                        Ticker = oleReader.GetString(2),
                        EquityType = EquityTypes.InternationalEquity,
                    };

                    edisRepo.InsertEquityData(equity);
                }
                oleReader.Close();
                oleConn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:stevenzhenhaowang,项目名称:EDIS,代码行数:45,代码来源:ImportExcelData.cs

示例2: DLookupA

        public object[] DLookupA(string table, string fieldName, string clauses, string[] orderByFieldNames, bool orderByAsc)
        {
            List<object> data = new List<object>();
            bool connectedP = isConnectedDo;
            string query = "";
            try
            {
                query = "SELECT " + fieldName + " FROM " + table + " WHERE (" + clauses + ")" + ((orderByFieldNames.Length > 0) ? " ORDER BY " + getOrderByData(orderByFieldNames) + " " + ((orderByAsc) ? "ASC" : "DESC") : "");

                if (dbType == DatabaseType.MSSQL)
                {
                    getQueryDbChanger(query, SqlTypes.SELECT);
                    SqlDataReader Dr = new SqlCommand(query, MSSQLConn).ExecuteReader();
                    while (Dr.Read())
                    {
                        data.Add(Dr[0]);
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MYSQL)
                {
                    MySqlDataReader Dr = new MySqlCommand(query, MySQLConn).ExecuteReader();
                    while (Dr.Read())
                    {
                        data.Add(Dr[0]);
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MSACCESS2003 | dbType == DatabaseType.MSACCESS2007)
                {
                    OleDbDataReader Dr = new OleDbCommand(query, MSDBSQLConn).ExecuteReader();
                    while (Dr.Read())
                    {
                        data.Add(Dr[0]);
                    }
                    Dr.Close();
                }
            }
            catch (Exception eee)
            {
                OnError(eee);
                data.Clear();
                data.Add("ERROR: " + eee.Message);
                data.Add("ERRORI: " + table);
                data.Add("ERRORI: " + fieldName);
                data.Add("ERRORI: " + clauses);
                data.Add("ERRORI: " + query);
            }
            finally
            {
                if (!connectedP)
                    closeConnection();
            }
            return data.ToArray();
        }
开发者ID:mrinc,项目名称:UsefulClasses,代码行数:55,代码来源:DatabaseConnection.cs

示例3: DLookup

        public object DLookup(string table, string fieldName, string clauses, string[] orderByFieldNames, bool orderByAsc)
        {
            object data = null;
            bool connectedP = isConnectedDo;
            try
            {
                string query = "SELECT TOP 1 " + fieldName + " FROM " + table + " WHERE (" + clauses + ")" + ((orderByFieldNames.Length > 0) ? " ORDER BY " + getOrderByData(orderByFieldNames) + " " + ((orderByAsc) ? "ASC" : "DESC") : "");

                if (dbType == DatabaseType.MSSQL)
                {
                    getQueryDbChanger(query, SqlTypes.SELECT);
                    SqlDataReader Dr = new SqlCommand(query, MSSQLConn).ExecuteReader();
                    if (Dr.Read())
                    {
                        data = Dr[0];
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MYSQL)
                {
                    MySqlDataReader Dr = new MySqlCommand(query, MySQLConn).ExecuteReader();
                    if (Dr.Read())
                    {
                        data = Dr[0];
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MSACCESS2003 | dbType == DatabaseType.MSACCESS2007)
                {
                    OleDbDataReader Dr = new OleDbCommand(query, MSDBSQLConn).ExecuteReader();
                    if (Dr.Read())
                    {
                        data = Dr[0];
                    }
                    Dr.Close();
                }
            }
            catch (Exception eee)
            {
                OnError(eee);
                data = eee.Message;
            }
            finally
            {
                if (!connectedP)
                    closeConnection();
            }
            return data;
        }
开发者ID:mrinc,项目名称:UsefulClasses,代码行数:49,代码来源:DatabaseConnection.cs

示例4: Logined1

 public void Logined1()
 {
     OleDbCommand oleDbCommand = new OleDbCommand("SELECT * FROM Player Where Id=" + Conversions.ToString(this._My_Id), Data.conn_Account);
     OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader();
     if (oleDbDataReader.Read())
     {
         this._My_Name = Conversions.ToString(oleDbDataReader["Name"]);
         this._My_Lv = Conversions.ToInteger(oleDbDataReader["Lv"]);
         this._My_Hp = Conversions.ToInteger(oleDbDataReader["Hp"]);
         this._My_HpMax = Conversions.ToInteger(oleDbDataReader["Hpmax"]);
         this._My_Sp = Conversions.ToInteger(oleDbDataReader["Sp"]);
         this._My_SpMax = Conversions.ToInteger(oleDbDataReader["Spmax"]);
         this._My_Point = Conversions.ToInteger(oleDbDataReader["Point"]);
         this._My_SkillPoint = Conversions.ToInteger(oleDbDataReader["SkillPoint"]);
         this._My_Int = Conversions.ToInteger(oleDbDataReader["Int"]);
         this._My_Atk = Conversions.ToInteger(oleDbDataReader["Atk"]);
         this._My_Def = Conversions.ToInteger(oleDbDataReader["Def"]);
         this._My_Hpx = Conversions.ToInteger(oleDbDataReader["Hpx"]);
         this._My_Spx = Conversions.ToInteger(oleDbDataReader["Spx"]);
         this._My_Agi = Conversions.ToInteger(oleDbDataReader["Agi"]);
         this._My_Int2 = Conversions.ToInteger(oleDbDataReader["Int2"]);
         this._My_Atk2 = Conversions.ToInteger(oleDbDataReader["Atk2"]);
         this._My_Def2 = Conversions.ToInteger(oleDbDataReader["Def2"]);
         this._My_Hpx2 = Conversions.ToInteger(oleDbDataReader["Hpx2"]);
         this._My_Spx2 = Conversions.ToInteger(oleDbDataReader["Spx2"]);
         this._My_Agi2 = Conversions.ToInteger(oleDbDataReader["Agi2"]);
         this._My_Texp = Conversions.ToInteger(oleDbDataReader["TExp"]);
         this._My_MapId = Conversions.ToInteger(oleDbDataReader["MapId"]);
         this._My_MapX = Conversions.ToInteger(oleDbDataReader["MapX"]);
         this._My_MapY = Conversions.ToInteger(oleDbDataReader["MapY"]);
         this._My_Reborn = Conversions.ToInteger(oleDbDataReader["Reborn"]);
         this._My_Job = Conversions.ToInteger(oleDbDataReader["Job"]);
         this._My_Sex = Conversions.ToInteger(oleDbDataReader["Sex"]);
         this._My_Hair = Conversions.ToInteger(oleDbDataReader["Hair"]);
         this._My_Thuoctinh = Conversions.ToInteger(oleDbDataReader["Thuoctinh"]);
         this._My_Ghost = Conversions.ToInteger(oleDbDataReader["Ghost"]);
         this._My_God = Conversions.ToInteger(oleDbDataReader["God"]);
         this._My_Color = Conversions.ToString(oleDbDataReader["Color"]);
         this._My_Gold = Conversions.ToInteger(oleDbDataReader["Gold"]);
         this._My_Tiengtam = Conversions.ToInteger(oleDbDataReader["Tiengtam"]);
         this._My_Gocnhin = Conversions.ToInteger(oleDbDataReader["Gocnhin"]);
         this._My_SttPetXuatChien = Conversions.ToInteger(oleDbDataReader["SttPetXuatChien"]);
         this._My_Pk = Conversions.ToInteger(oleDbDataReader["Pk"]);
         this._My_ThamChien = Conversions.ToInteger(oleDbDataReader["ThamChien"]);
     }
     oleDbDataReader.Close();
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._hpx, this._My_Hpx);
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._spx, this._My_Spx);
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._atk, this._My_Atk);
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._def, this._My_Def);
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._Int, this._My_Int);
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._agi, this._My_Agi);
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._Hp, this._My_Hp);
     Data.PlayerUpdateStatus(this._My_Id, DataStructure.Type_Status._Sp, this._My_Sp);
     string text = "";
     string text2 = "";
     DataStructure.HomdoInfo homdoInfo = Data.TrangbiGetDataItem(this.conn, 1);
     DataStructure.HomdoInfo homdoInfo2 = Data.TrangbiGetDataItem(this.conn, 2);
     DataStructure.HomdoInfo homdoInfo3 = Data.TrangbiGetDataItem(this.conn, 3);
     DataStructure.HomdoInfo homdoInfo4 = Data.TrangbiGetDataItem(this.conn, 4);
     DataStructure.HomdoInfo homdoInfo5 = Data.TrangbiGetDataItem(this.conn, 5);
     DataStructure.HomdoInfo homdoInfo6 = Data.TrangbiGetDataItem(this.conn, 6);
     int iD = homdoInfo._ID;
     int iD2 = homdoInfo2._ID;
     int iD3 = homdoInfo3._ID;
     int iD4 = homdoInfo4._ID;
     int iD5 = homdoInfo5._ID;
     int iD6 = homdoInfo6._ID;
     int doben = homdoInfo._Doben;
     int doben2 = homdoInfo2._Doben;
     int doben3 = homdoInfo3._Doben;
     int doben4 = homdoInfo4._Doben;
     int doben5 = homdoInfo5._Doben;
     int doben6 = homdoInfo6._Doben;
     int @long = homdoInfo._Long;
     int long2 = homdoInfo2._Long;
     int long3 = homdoInfo3._Long;
     int long4 = homdoInfo4._Long;
     int long5 = homdoInfo5._Long;
     int long6 = homdoInfo6._Long;
     int giatriLong = homdoInfo._GiatriLong;
     int giatriLong2 = homdoInfo2._GiatriLong;
     int giatriLong3 = homdoInfo3._GiatriLong;
     int giatriLong4 = homdoInfo4._GiatriLong;
     int giatriLong5 = homdoInfo5._GiatriLong;
     int giatriLong6 = homdoInfo6._GiatriLong;
     int khang = homdoInfo._Khang;
     int khang2 = homdoInfo2._Khang;
     int khang3 = homdoInfo3._Khang;
     int khang4 = homdoInfo4._Khang;
     int khang5 = homdoInfo5._Khang;
     int khang6 = homdoInfo6._Khang;
     int tExp = homdoInfo._TExp;
     int tExp2 = homdoInfo2._TExp;
     int tExp3 = homdoInfo3._TExp;
     int tExp4 = homdoInfo4._TExp;
     int tExp5 = homdoInfo5._TExp;
     int tExp6 = homdoInfo6._TExp;
     checked
     {
//.........这里部分代码省略.........
开发者ID:daviastroaw,项目名称:newts,代码行数:101,代码来源:Client.cs

示例5: getFieldList

 public virtual string getFieldList(string argString)
 {
     string cmdText = argString;
     string argObject = "";
     try
     {
         string connStr = this.connStr;
         string argRoutestr = cls.getParameter(connStr, "Data Source");
         string newValue = HttpContext.Current.Server.MapPath(cls.getActualRoute(argRoutestr));
         OleDbConnection connection = new OleDbConnection(connStr.Replace(argRoutestr, newValue));
         connection.Open();
         OleDbDataReader reader = new OleDbCommand(cmdText, connection).ExecuteReader();
         int fieldCount = reader.FieldCount;
         for (int i = 0; i < fieldCount; i++)
         {
             argObject = argObject + reader.GetName(i) + "|";
         }
         if (!cls.isEmpty(argObject))
         {
             argObject = cls.getLRStr(argObject, "|", "leftr");
         }
         reader.Close();
         connection.Close();
     }
     catch (Exception exception)
     {
         argObject = "";
         this.eMessage = exception.Message;
     }
     return argObject;
 }
开发者ID:dengfan,项目名称:jtbc-plus,代码行数:31,代码来源:access.cs

示例6: getDataAry

 public virtual object[] getDataAry(string argString)
 {
     this.rState = 0;
     string cmdText = argString;
     object[] objArray = null;
     try
     {
         string connStr = this.connStr;
         string argRoutestr = cls.getParameter(connStr, "Data Source");
         string newValue = HttpContext.Current.Server.MapPath(cls.getActualRoute(argRoutestr));
         OleDbConnection connection = new OleDbConnection(connStr.Replace(argRoutestr, newValue));
         connection.Open();
         OleDbDataReader reader = new OleDbCommand(cmdText, connection).ExecuteReader();
         int fieldCount = reader.FieldCount;
         object[,] objArray2 = null;
         while (reader.Read())
         {
             objArray2 = new object[fieldCount, 2];
             for (int i = 0; i < fieldCount; i++)
             {
                 objArray2[i, 0] = reader.GetName(i);
                 objArray2[i, 1] = reader.GetValue(i);
             }
             objArray = cls.mergeAry(objArray, objArray2);
         }
         reader.Close();
         connection.Close();
     }
     catch (Exception exception)
     {
         this.rState = 1;
         objArray = null;
         this.eMessage = exception.Message;
     }
     return objArray;
 }
开发者ID:dengfan,项目名称:jtbc-plus,代码行数:36,代码来源:access.cs

示例7: getFieldList

 public virtual string getFieldList(string argString)
 {
     string cmdText = argString;
     string argObject = "";
     try
     {
         OleDbConnection connection = new OleDbConnection(this.connStr);
         connection.Open();
         OleDbDataReader reader = new OleDbCommand(cmdText, connection).ExecuteReader();
         int fieldCount = reader.FieldCount;
         for (int i = 0; i < fieldCount; i++)
         {
             argObject = argObject + reader.GetName(i) + "|";
         }
         reader.Close();
         connection.Close();
     }
     catch (Exception exception)
     {
         argObject = "";
         this.eMessage = exception.Message;
     }
     return argObject;
 }
开发者ID:liuzhenwei,项目名称:VS,代码行数:24,代码来源:access.cs

示例8: getDataAry

		public virtual Dictionary<string, object>[] getDataAry(string strSQL)
        {
            this.rState = 0;
			Dictionary<string, object>[] rsArray = null;
			if ((string)strSQL != "")
            {
				try
				{
					OleDbConnection connection = new OleDbConnection(this.connStr);
					connection.Open();
					OleDbDataReader reader = new OleDbCommand(strSQL, connection).ExecuteReader();
					Dictionary<int, object> rsList = new Dictionary<int, object>();
					int fieldCount = reader.FieldCount;
					int num = 0;
					while (reader.Read())
					{
						Dictionary<string, object> rec = new Dictionary<string, object>();
						for (int i = 0; i < fieldCount; i++)
						{
							rec.Add(reader.GetName(i), reader.GetValue(i));
						}
						rsList.Add(num, rec);
						num ++;
					}
					reader.Close();
					connection.Close();

					rsArray = new Dictionary<string, object>[num];
					foreach (var kv in rsList)
					{
						rsArray[kv.Key] = (Dictionary<string, object>)kv.Value;
					}
				}
				catch (Exception exception)
				{
					this.rState = 1;
					var errMsg = new Dictionary<string, object>();
					errMsg.Add("msg", "Operate DB Error: " + exception.Message);
					rsArray = new Dictionary<string, object>[] { errMsg };
					this.eMessage = exception.Message;
				}
			}
			else
			{
				this.rState = 999;
			}
			return rsArray;
        }
开发者ID:liuzhenwei,项目名称:VS,代码行数:48,代码来源:access.cs


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