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


C# IDbCommand.ExecuteReader方法代码示例

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


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

示例1: StarStart

    public static void StarStart()
    {
        ///////////////////////////////////////////////////////////////////[DB Query]
        dbcmd = dbconn.CreateCommand();
        string sqlQuery = "SELECT * FROM userTable";
        dbcmd.CommandText = sqlQuery;
        ///////////////////////////////////////////////////////////////////[DB Query]

        int cnt = 0;
        reader = dbcmd.ExecuteReader();
        while (reader.Read())
        {
            StarSingleTon.Instance.cPlanet = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cFood = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cTitanium = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cRE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cYE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cBE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cOE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cGE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cVE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.cPE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.shipNum = reader.GetInt32(cnt++);

            cnt = 0;
        }
        cnt = 0;

        reader.Close();
        reader = null;

        sqlQuery = "SELECT * FROM zodiacTable WHERE rowid =" + StarSingleTon.Instance.rowid;

        dbcmd.CommandText = sqlQuery;
        reader = dbcmd.ExecuteReader();
        while (reader.Read())
        {
            StarSingleTon.Instance.zID = reader.GetString(cnt++);
            StarSingleTon.Instance.zodiac = reader.GetString(cnt++);
            StarSingleTon.Instance.zName = reader.GetString(cnt++);
            StarSingleTon.Instance.locationX = reader.GetFloat(cnt++);
            StarSingleTon.Instance.locationY = reader.GetFloat(cnt++);
            StarSingleTon.Instance.locationZ = reader.GetFloat(cnt++);
            StarSingleTon.Instance.zOpen = reader.GetBoolean(cnt++);
            StarSingleTon.Instance.zFind = reader.GetBoolean(cnt++);
            StarSingleTon.Instance.needPE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.nowPE = reader.GetInt32(cnt++);
            StarSingleTon.Instance.zActive = reader.GetBoolean(cnt++);

            cnt = 0;
        }
        cnt = 0;
        reader.Close();
        reader = null;

        StarSingleTon.Instance.setMainText();
        StarSingleTon.Instance.setPointlight();
    }
开发者ID:Gibom,项目名称:Unity3D,代码行数:58,代码来源:StarSceneSql.cs

示例2: BasicQuery

	IDataReader BasicQuery(string query){ // run a basic Sqlite query
		dbcmd = dbcon.CreateCommand(); // create empty command
		dbcmd.CommandText = query; // fill the command
		reader = dbcmd.ExecuteReader(); // execute command which returns a reader
		return reader; // return the reader
	
	}
开发者ID:BernardoOM,项目名称:Making-Time,代码行数:7,代码来源:dbAccess.cs

示例3: createNewCharacter

        public UInt32 createNewCharacter(string handle, UInt32 userid, UInt32 worldId)
        {
            conn.Open();
            UInt32 charId = 0;
            //TODO: Complete with real data from a hashtable (or something to do it faster);
            //TODO: find values for uria starting place
            string sqlInsertQuery="INSERT INTO characters SET userid = '" + userid.ToString() + "', worldid='" + worldId.ToString() + "', status='0', handle = '" + handle + "', created=NOW() ";
            queryExecuter= conn.CreateCommand();
            queryExecuter.CommandText = sqlInsertQuery;
            queryExecuter.ExecuteNonQuery();

            //As i didnt find a solution for "last_insert_id" in C# we must fetch the last row by a normal query
            string sqlQuery = "SELECT charId FROM characters WHERE userId='" + userid.ToString() + "' AND worldId='" + worldId.ToString() + "' AND is_deleted='0' ORDER BY charId DESC LIMIT 1";
            queryExecuter = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            while (dr.Read())
            {
                charId = (UInt32)dr.GetDecimal(0);
            }

            conn.Close();

            // Create RSI Entry
            conn.Open();
            string sqlRSIQuery = "INSERT INTO rsivalues SET charid='" + charId.ToString() + "' ";
            queryExecuter = conn.CreateCommand();
            queryExecuter.CommandText = sqlRSIQuery;
            queryExecuter.ExecuteNonQuery();

            conn.Close();

            return charId;
        }
开发者ID:hdneo,项目名称:mxo-hd,代码行数:35,代码来源:MyMarginDBAccess.cs

示例4: OracleBlobOutputStream

		/// <summary>
		/// Creates a new instance of the <see cref="SqlClientInputStream" /> class for the specified connection string, table
		/// data field, and where criteria.
		/// </summary>
		/// <param name="connectionString">The connection string of the database to use.</param>
		/// <param name="table">The table in which the data is stored.</param>
		/// <param name="dataField">The field in which the data is stored</param>
		/// <param name="whereCriteria">The where criteria that identifies the record.</param>
		public OracleBlobOutputStream(string connectionString, string table, string dataField, string whereCriteria)
		{
			// TODO: add buffering
			_cn = OracleBlobUploadStreamProvider.CreateConnection(connectionString);
			_cmd = _cn.CreateCommand();

            _cmd.CommandText = "SELECT " + dataField + " FROM " + table + " WHERE " + whereCriteria;

            try
            {
                _cn.Open();

                IDataReader rd = _cmd.ExecuteReader(CommandBehavior.SingleRow);

                rd.Read();

                object blob = rd.GetType().InvokeMember("GetOracleBlob", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, rd, new object[] {0});

                _blob = new ReflectWrapper(blob);
            }
            catch
            {
				_cn.Close();
			}
		}
开发者ID:codingbat,项目名称:BandCamp,代码行数:33,代码来源:OracleBlobOutputStream.cs

示例5: Start

    // Use this for initialization
    void Start()
    {
        OpenDB("MakingTime.db");
       _dbcm = _dbc.CreateCommand();
      
        //Insert data 
        sqlQuery = "INSERT INTO Event (name,current_day,current_time,min_day,max_day,min_time,max_time,scheduled,creator,type) VALUES ('Date',1,1,0,3,2,3,1,'Robert','Social')";
        _dbcm.CommandText = sqlQuery;
        _dbcm.ExecuteNonQuery();

        sqlQuery = "INSERT INTO Event (name,current_day,current_time,min_day,max_day,min_time,max_time,scheduled,creator,type) VALUES ('Party',1,1,0,3,2,3,1,'Gina','Social')";
        _dbcm.CommandText = sqlQuery;
        _dbcm.ExecuteNonQuery();

        sqlQuery = "INSERT INTO Event (name,current_day,current_time,min_day,max_day,min_time,max_time,scheduled,creator,type) VALUES ('Movie',1,1,0,3,2,3,1,'Robert','Social')";
        _dbcm.CommandText = sqlQuery;
        _dbcm.ExecuteNonQuery();

        sqlQuery = "select * from Event";
        _dbcm.CommandText = sqlQuery;
        _dbr = _dbcm.ExecuteReader();

        while (_dbr.Read())
        {
            Debug.Log("****** Data: " + _dbr["name"] + "\tday: " + _dbr["current_day"] + "\tTime: " + _dbr["current_time"] + "\tMin Day: " + _dbr["min_day"]
                + "\tMax Day: " + _dbr["max_day"] + "\tMin Time: " + _dbr["min_time"] + "\tMax Time: " + _dbr["max_time"] + "\tScheduled: " + _dbr["scheduled"]
                + "\tcreator: " + _dbr["creator"] + "\ttype: " + _dbr["type"]);
        }
        _dbr.Close();
        _dbr = null;
        _dbcm.Dispose();
        _dbcm = null;
        _dbc.Close();
        _dbc = null;
    }
开发者ID:BernardoOM,项目名称:Making-Time,代码行数:36,代码来源:DBMakingTime.cs

示例6: ReadRandomNewCommitment

	public static void ReadRandomNewCommitment(string event_Type, ref string name, ref int time_Length,
	                                           ref int maxTime, ref int minTime)
	{
		OpenDB("MakingTime.db");
		_dbcm = _dbc.CreateCommand();

		sqlQuery = "select count(*) as NumberOfRegions from Event_Type where Category = '" + event_Type + "'";
		_dbcm.CommandText = sqlQuery;
		Int32 rows = Convert.ToInt32(_dbcm.ExecuteScalar());

		sqlQuery = "select * from Event_Type where Category = '" + event_Type + "'";
		_dbcm.CommandText = sqlQuery;
		_dbr = _dbcm.ExecuteReader();

		int commitmentRow = UnityEngine.Random.Range(0, rows);
		//Question 
		for(int countRows = 0; countRows < commitmentRow + 1; countRows += 1)
		{	
			_dbr.Read();	
		}

		name = _dbr.GetString(0);
		time_Length = _dbr.GetInt32(1);
		maxTime = _dbr.GetInt32(8);
		minTime = _dbr.GetInt32(7);

		_dbr.Close();
		_dbr = null;
		_dbcm.Dispose();
		_dbcm = null;
		_dbc.Close();
		_dbc = null;
	}
开发者ID:BernardoOM,项目名称:Making-Time,代码行数:33,代码来源:DBMakingTime.cs

示例7: CreateDropAllObjectsStatements

        private static IEnumerable<string> CreateDropAllObjectsStatements(IDbCommand cmd)
        {
            cmd.CommandText = @"SELECT stmt FROM (SELECT CASE WHEN type = 'AF'                           THEN 'DROP AGGREGATE ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                              WHEN type IN('C', 'F', 'UQ')               THEN 'ALTER TABLE ' + QUOTENAME(object_schema_name(parent_object_id)) + '.' + QUOTENAME(object_name(parent_object_id)) + ' DROP CONSTRAINT ' + QUOTENAME(name)
                                                              WHEN type IN('FN', 'FS', 'FT', 'IF', 'TF') THEN 'DROP FUNCTION ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                              WHEN type IN('P', 'PC')                    THEN 'DROP PROCEDURE ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                              WHEN type = 'R'                            THEN 'DROP RULE ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                              WHEN type = 'SN'                           THEN 'DROP SYNONYM ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                              WHEN type = 'U'                            THEN 'DROP TABLE ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                              WHEN type IN('TA', 'TR')                   THEN 'DROP TRIGGER ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                              WHEN type = 'V'                            THEN 'DROP VIEW ' + QUOTENAME(schema_name(schema_id)) + '.' + QUOTENAME(name)
                                                         END stmt, type
                                                    FROM sys.objects) x
                                 WHERE stmt IS NOT NULL
                                 ORDER BY CASE WHEN type IN('C', 'F', 'UQ', 'TA', 'TR') THEN 1 ELSE 2 END";

            var result = new List<string>();
            using (var rdr = cmd.ExecuteReader())
            {
                while (rdr.Read())
                {
                    result.Add((string)rdr[0]);
                }
            }
            return result;
        }
开发者ID:RichieYang,项目名称:Composable.Monolithic,代码行数:26,代码来源:DatabaseHelpers.cs

示例8: fetchWordList

        public bool fetchWordList(ref WorldList wl)
        {
            // Doesnt exist by default
            wl.setExistance(false);

            string sqlQuery = "select * from users where username='"+wl.getUsername()+"' and passwordmd5='"+wl.getPassword()+"';";
            queryExecuter= conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr= queryExecuter.ExecuteReader();

            while(dr.Read()){
                // Player is on the DB
                wl.setExistance(true);
                wl.setUserID((int) dr.GetDecimal(0));
                dr.GetBytes(6,0,wl.getPrivateExponent(),0,96);
                dr.GetBytes(5,0,wl.getPublicModulus(),0,96);
                wl.setTimeCreated((int)dr.GetDecimal(7));
            }

            dr.Close();

            // If doesnt exist... should not do more things
            if (!wl.getExistance()){
                Output.writeToLogForConsole("[WORLD DB ACCESS] fetchWordList : Player not found on DB with #" + wl.getUsername() + "# and #" + wl.getPassword() + "#");
                conn.Close();
                return false;
            }
            return true;
        }
开发者ID:hdneo,项目名称:mxo-hd,代码行数:29,代码来源:MyWorldDbAccess.cs

示例9: GetTripFormResponses

        private List<TripFormResponse> GetTripFormResponses(IDbCommand command)
        {
            var connection = _dbConnection;
            try
            {
                connection.Open();

                command.Connection = connection;
                var reader = command.ExecuteReader();
                var responses = new List<TripFormResponse>();
                while (reader.Read())
                {
                    var response = new TripFormResponse();
                    response.ContactId = reader.GetInt32(reader.GetOrdinal("Contact_ID"));
                    var donorId = SafeInt32(reader, "Donor_ID");
                    response.DonorId = donorId;
                    response.FundraisingGoal = SafeDecimal(reader,"Fundraising_Goal");
                    response.ParticipantId = reader.GetInt32(reader.GetOrdinal("Participant_ID"));
                    response.PledgeCampaignId = SafeInt32(reader, "Pledge_Campaign_ID");
                    response.EventId = SafeInt32(reader, "Event_ID");
                    response.DestinationId = reader.GetInt32(reader.GetOrdinal("Destination_ID"));

                    responses.Add(response);
                }
                return responses;
            }
            finally
            {
                connection.Close();
            }
        }
开发者ID:plachmann,项目名称:crds-angular,代码行数:31,代码来源:FormSubmissionService.cs

示例10: DeleteTableContents

 // This function deletes all the data in the given table.  Forever.  WATCH OUT! Use sparingly, if at all
 public void DeleteTableContents(string tableName)
 {
     string query;
     query = "DELETE FROM " + tableName;
     dbcmd = dbcon.CreateCommand();
     dbcmd.CommandText = query;
     reader = dbcmd.ExecuteReader();
 }
开发者ID:dslwz2008,项目名称:crowd-evacuation,代码行数:9,代码来源:SqliteDB.cs

示例11: ExecuteQueryReader

 public IDataReader ExecuteQueryReader(IDbCommand command)
 {
     using (SqlConnection conn = GetConnection() as SqlConnection)
     {
         command.Connection = conn;
         return command.ExecuteReader();
     }
 }
开发者ID:AndreiAnufrijev,项目名称:dotnet-coding-test,代码行数:8,代码来源:MsSqlConnection.cs

示例12: Execute

        public IDataReader Execute(IDbCommand cmd)
        {
            cmd.CommandText = ToString();
            whereHelper.Command = cmd;
            whereHelper.AppendValues();

            return cmd.ExecuteReader();
        }
开发者ID:geofflane,项目名称:zorched-migrations,代码行数:8,代码来源:SqlSelectOperation.cs

示例13: ManagedDataReader

 public ManagedDataReader(IDbCommand command)
 {
     _command = command;
     _connection = command.Connection;
     if(_connection.State != ConnectionState.Open) _connection.Open();
     _dataReader = command.ExecuteReader();
     
 }
开发者ID:NHSChoices,项目名称:location-service,代码行数:8,代码来源:ManagedDataReader.cs

示例14: DumpTerminology

        protected void DumpTerminology(IDbCommand cmd, string sProcedureName, int nNAME_MaxLength)
        {
            using ( SqlDataReader rdr = (SqlDataReader) cmd.ExecuteReader() )
            {
                int nCount = 0;
                while ( rdr.Read() )
                {
                    // 04/29/2006 Paul.  DB2 is having a heap error SQL0954C.
                    // Increase the size of the heap and decrease the size of the procedure.
                    // db2 => connect to splendid
                    // 1)	update db cfg for splendid using applheapsz 1024
                    if ( nCount > 250 )
                    {
                        Response.Write("/* -- #if Oracle" + ControlChars.CrLf);
                        Response.Write("	COMMIT WORK;" + ControlChars.CrLf);
                        Response.Write("END;" + ControlChars.CrLf);
                        Response.Write("/" + ControlChars.CrLf);

                        Response.Write(ControlChars.CrLf);
                        Response.Write("BEGIN" + ControlChars.CrLf);
                        Response.Write("-- #endif Oracle */" + ControlChars.CrLf);
                        nCount = 0;
                    }
                    nCount++;
                    Response.Write("exec dbo." + sProcedureName + " ");
                    for ( int nColumn=0 ; nColumn < rdr.FieldCount ; nColumn++ )
                    {
                        if ( nColumn > 0 )
                            Response.Write(", ");
                        if ( rdr.IsDBNull(nColumn) )
                            Response.Write("null");
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Boolean" ) ) Response.Write(rdr.GetBoolean (nColumn) ? "1" : "0" );
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Single"  ) ) Response.Write(rdr.GetDouble  (nColumn).ToString());
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Double"  ) ) Response.Write(rdr.GetDouble  (nColumn).ToString());
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Int16"   ) ) Response.Write(rdr.GetInt16   (nColumn).ToString());
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Int32"   ) ) Response.Write(rdr.GetInt32   (nColumn).ToString());
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Int64"   ) ) Response.Write(rdr.GetInt64   (nColumn).ToString());
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Decimal" ) ) Response.Write(rdr.GetDecimal (nColumn).ToString());
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.DateTime") ) Response.Write("\'" + rdr.GetDateTime(nColumn).ToString("yyyy-MM-dd HH:mm:ss") + "\'");
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.Guid"    ) ) Response.Write("\'" + rdr.GetGuid  (nColumn).ToString().ToUpper() + "\'");
                        else if ( rdr.GetFieldType(nColumn) == Type.GetType("System.String"  ) ) Response.Write("\'" + rdr.GetString(nColumn).Replace("\'", "\'\'") + "\'");
                        else Response.Write("null");
                        // 11/21/2005 Paul.  Align the name field.
                        if ( nColumn == 0 )
                        {
                            string sNAME = rdr.GetString(nColumn);
                            if ( nNAME_MaxLength - sNAME.Length > 0 )
                                Response.Write(Strings.Space(nNAME_MaxLength - sNAME.Length));
                        }
                    }
                    Response.Write(";" + ControlChars.CrLf);
                }
                if ( Sql.IsOracle(cmd) || Sql.IsDB2(cmd) )
                    Response.Write("/" + ControlChars.CrLf + ControlChars.CrLf);
                if ( Sql.IsSQLServer(cmd) )
                    Response.Write("GO" + ControlChars.CrLf + ControlChars.CrLf);
            }
        }
开发者ID:NALSS,项目名称:splendidcrm-99885,代码行数:58,代码来源:Terminology.aspx.cs

示例15: ExecuteReadCommand

 // Ридэр
 public IDataReader ExecuteReadCommand(IDbCommand command)
 {
     IDataReader dataReader = null;
     if (DatabaseConnection.State == ConnectionState.Open)
     {
         dataReader = command.ExecuteReader();
     }
     return dataReader;
 }
开发者ID:powerfxxx,项目名称:passext,代码行数:10,代码来源:Connector.cs


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