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


C# OdbcDataReader.Read方法代码示例

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


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

示例1: DisplayRecords

        /// <summary>
        /// DisplayRecords: This function displays the records in the view if any.
        /// </summary>
        static void DisplayRecords()
        {
            Console.Write("\tRecord in getpatientbalance stored procedure");

            try
            {
                reader = (OdbcDataReader)command.ExecuteReader();
                // read the returned resultset
                while (reader.Read())
                {
                    /*
                     * This view consists the following fields:
                     * pat_id
                     * pat_0_30_days
                     * pat_31_60_days
                     * pat_61_90_days
                     * pat_91_120_days
                     * pat_121_plus_days
                     * last_pmt_date
                     * last_pmt_amt
                     * last_pmt_type
                     * last_pmt_desc
                     */
                    Console.WriteLine("\npat_id:{0}\npat_0_30_days: {1}\npat_31_60_days: {2} \npat_61_90_days: {3}\npat_91_120_plus_days: {4} \npat_121_plus_days: {5}\nlast_pmt_date: {6} \nlast_pmt_amt: {7}\nlast_pmt_type: {8}\nlast_pmt_desc: {9}",
                        reader.GetValue(0), reader.GetValue(1), reader.GetValue(2), reader.GetValue(3), reader.GetValue(4), reader.GetValue(5), reader.GetValue(6), reader.GetValue(7), reader.GetValue(8), reader.GetValue(9));
                }
                // close the reader
                reader.Close();
            }
            catch (Exception e)
            {
                ExceptionDisplay(e);
            }
        }
开发者ID:cgabilla,项目名称:cKarp,代码行数:37,代码来源:StoredProcedureTutorial.cs

示例2: formatTasks

 public XDocument formatTasks(OdbcDataReader r)
 {
     xdoc = new XDocument();
     XElement title, notes, startdatetime, enddatetime, place, id;
     XElement root = new XElement("message");
     XAttribute type = new XAttribute("type", "tasks");
     XAttribute errorStatus = new XAttribute("error_status", "0");
     root.Add(type);
     XElement tasks = new XElement("tasks");
     while (r.Read())
     {
         XElement task = new XElement("task");
         id = new XElement("id", r.GetValue(0).ToString());
         task.Add(id);
         title = new XElement("title", r.GetValue(1).ToString());
         task.Add(title);
         notes = new XElement("notes", r.GetValue(2).ToString());
         task.Add(notes);
         startdatetime = new XElement("startdatetime", r.GetValue(3).ToString());
         task.Add(startdatetime);
         enddatetime = new XElement("enddatetime", r.GetValue(4).ToString());
         task.Add(enddatetime);
         place = new XElement("place", r.GetValue(5).ToString());
         task.Add(place);
         tasks.Add(task);
     }
     root.Add(tasks);
     root.Add(errorStatus);
     xdoc.Add(root);
     return xdoc;
 }
开发者ID:Palethorn,项目名称:Scheduler,代码行数:31,代码来源:MessageFormatter.cs

示例3: DisplayRecords

        /// <summary>
        /// DisplayRecords: This function displays the records in the view if any.
        /// </summary>
        static void DisplayRecords()
        {
            Console.Write("\tRecords in Prescirption list...");

            try
            {
                reader = (OdbcDataReader)command.ExecuteReader();
                // read the returned resultset
                while (reader.Read())
                {
                    /*
                     * This view consists the following fields:
                     * rxdef_id (TINYINT)
                     * drug_name (CHARACTER 50)
                     * description (CHARACTER 50)
                     * rx_date (DATE)
                     * For the purpose of keeping it simple, we are displaying the rxdef_id and drug_name on the console (the first two fields)
                     */
                    Console.WriteLine("\n\t\t{0}  {1}  ", reader.GetInt16(0), reader.GetString(1));
                }
                // close the reader
                reader.Close();
            }
            catch (Exception e)
            {
                ExceptionDisplay(e);
            }
        }
开发者ID:cgabilla,项目名称:cKarp,代码行数:31,代码来源:M6DtxConnector.cs

示例4: BeginHandling

 //initializing the leader handler
 public void BeginHandling()
 {
     try
     {
         //writer.WriteLine("I am not done");
         command = " SELECT T.Number, T.Assigner, T.Issue_Date, I.Assigned, I.Attachment, I.JobDone, I.Status, I.Sequence, I.Due_Date, I.Requirements" +
                 " FROM Ticket AS T, Ticket_Information AS I" +
                 " WHERE T.Number=I.Number AND I.Assigned='" + userName +
                 "' AND (I.Status = 'Assigned' OR I.Status='Waiting' OR I.Status='Work_In_Progress') AND I.Due_Date > #" + System.DateTime.Now + "#";
         sqlCommand = new OdbcCommand(command, dbConn);
         dbReader = sqlCommand.ExecuteReader();
         //Console.WriteLine("I am done");
         while (dbReader.Read())
         {
             line = "";//empty the line so you can read the next row
             for (int i = 0; i < dbReader.FieldCount - 1; i++)
             {
                 line += dbReader.GetString(i) + "##";// but the whole row in one column and send it, seperated by commas
             }
             writer.WriteLine(line);
             writer.Flush();
         }
         writer.WriteLine(".");// end of reading from the database
         writer.Flush();
         DB_Handler.DisposeAll(sqlCommand, dbReader);
         WaitForQueries();
         //do not forget to close the reader
     }
     catch
     {
         Console.WriteLine(" The Database is down please try again later");//for debugging server
     }
 }
开发者ID:hsnamr,项目名称:ARS-Server,代码行数:34,代码来源:HandleMember.cs

示例5: BeginHandling

 //initializing the leader handler
 public void BeginHandling()
 {
     try
     {
         email = DB_Handler.GetEmail(userName, dbConn);
         // command = " SELECT T.Number, T.Issue_Date, I.Assigned, I.Attachment, I.JobDone, I.Status, I.Sequence, I.Due_Date, I.Requirements" +
         //        " FROM Ticket AS T, Ticket_Information AS I WHERE T.Number=I.Number";
         command = " SELECT T.Number, T.Issue_Date, I.Assigned,I.Status, I.Due_Date" +
                 " FROM Ticket AS T, Ticket_Information AS I WHERE T.Number=I.Number AND T.Assigner ='" + userName + "'";
         sqlCommand = new OdbcCommand(command, dbConn);
         dbReader = sqlCommand.ExecuteReader();
         while (dbReader.Read())
         {
             line = "";//empty the line so you can read the next row
             for (int i = 0; i < dbReader.FieldCount-1; i++)
             {
                 line += dbReader.GetString(i) + "##";// but the whole row in one column and send it, seperated by commas
             }
             writer.WriteLine(line);
             writer.Flush();
         }
         writer.WriteLine(".");// end of reading from the database
         writer.Flush();
         DB_Handler.DisposeAll(sqlCommand, dbReader);
         WaitForQueries();
     }
     catch
     {
         Console.WriteLine(" The Database is down please try again later");//for debugging server
         DB_Handler.DisposeAll(sqlCommand, dbReader);
     }
 }
开发者ID:hsnamr,项目名称:ARS-Server,代码行数:33,代码来源:HandleLeader.cs

示例6: InsertData

public static void InsertData(OdbcDataReader read)
{
string table = @"d:\documents and settings\axkhan2\desktop\437proj\mytariff.dbf";
string query = "insert into " + table + "values (@ln, @orgcity, @destcity, @orgzone, @destzone, @ocountry, @dcountry, @orgcountry, @destcountry)"; //, @origin, @dest, @min, @rate, @rate, @basert, @frmwt, @towt, @cur, @validfrm, @validtill, @filename	
OleDbConnection con = new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=d:\documents and settings\axkhan2\desktop\437proj\");
try
{
OleDbCommand cmd = new OleDbCommand(query, con);
con.Open();
while(read.Read())
{
cmd.Parameters.Add(new OleDbParameter("@ln", Convert.ToInt32(read[0].ToString())));
cmd.Parameters.Add(new OleDbParameter("@orgcity", read[2].ToString()));
cmd.Parameters.Add(new OleDbParameter("@destcity", read[5].ToString()));
cmd.Parameters.Add(new OleDbParameter("@orgzone", read[4].ToString()));
cmd.Parameters.Add(new OleDbParameter("@destzone", read[7].ToString()));
cmd.Parameters.Add(new OleDbParameter("@ocountry", read[2].ToString()));
cmd.Parameters.Add(new OleDbParameter("@dcountry", read[6].ToString()));
cmd.Parameters.Add(new OleDbParameter("@orgcountry", "NL"));
cmd.Parameters.Add(new OleDbParameter("@destcountry", "FI"));

/*cmd.Parameters.Add(new OleDbParameter("origin", String.Empty));
cmd.Parameters.Add(new OleDbParameter("dest", String.Empty));
cmd.Parameters.Add(new OleDbParameter("min", double.Parse(read[10].ToString())));
cmd.Parameters.Add(new OleDbParameter("basert", null));
cmd.Parameters.Add(new OleDbParameter("rate", null));
cmd.Parameters.Add(new OleDbParameter("frmwt", null));
cmd.Parameters.Add(new OleDbParameter("towt", null));
cmd.Parameters.Add(new OleDbParameter("cur", null));
cmd.Parameters.Add(new OleDbParameter("validfrm", null));
cmd.Parameters.Add(new OleDbParameter("validtill", null));
*/
/*cmd.Parameters.Add(new OleDbParameter("rate", double.Parse(read["rate"].ToString())));
cmd.Parameters.Add(new OleDbParameter("frmwt", double.Parse(read["from_wt"].ToString())));
cmd.Parameters.Add(new OleDbParameter("towt", double.Parse(read["to_wt"].ToString())));
cmd.Parameters.Add(new OleDbParameter("cur", read["currency"].ToString()));
cmd.Parameters.Add(new OleDbParameter("validfrm", DateTime.Parse(read["valid_from"].ToString())));
cmd.Parameters.Add(new OleDbParameter("validtill", DateTime.Parse(read["valid_till"].ToString())));
*/
cmd.Parameters.Add(new OleDbParameter("validtill", "mytariff.xls"));

cmd.ExecuteNonQuery();
}
}
catch(OleDbException ex)
{
Console.WriteLine(ex.Message);
}
finally 
{
con.Close();
}

}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:54,代码来源:example1.cs

示例7: PrintResults

 private static void PrintResults(OdbcDataReader reader) {
   for (int ii = 0; ii < reader.FieldCount; ii += 1) {
     System.Console.Write("{0}{1}",
         reader.GetName(ii),
         ii + 1 < reader.FieldCount ? "\t" : "\n");
   }
   while (reader.Read()) {
     for (int ii = 0; ii < reader.FieldCount; ii += 1) {
       System.Console.Write("{0}{1}",
           reader.GetValue(ii),
           ii + 1 < reader.FieldCount ? "\t" : "\n");
     }
   }
 }
开发者ID:t4ku,项目名称:bigquery-e2e,代码行数:14,代码来源:bigquery_odbc.cs

示例8: convertOdbcDataToList

        public static List<List<string>> convertOdbcDataToList(OdbcDataReader reader)
        {
            List<List<string>> lr = new List<List<string>>();
            while(reader.Read())
            {
                List<string> lsItem = new List<string>();

                for (int i = 0; i < reader.FieldCount; i++)
                {
                    lsItem.Add(reader[i].ToString());
                }
                lr.Add(lsItem);
            }
            return lr;
        }
开发者ID:budlion,项目名称:DSTPRJ,代码行数:15,代码来源:StringUtil.cs

示例9: IsExists

 public bool IsExists(string sQuery)
 {
     m_dataReader = null;
     m_odbcCommand.CommandText = sQuery;
     try
     {
         OpenDB();
         m_dataReader = m_odbcCommand.ExecuteReader(CommandBehavior.CloseConnection);
         if (m_dataReader.Read())
             return true;
     }
     catch
     {
         ;
     }
     finally
     {
         CloseDB(1);
     }
     return false;
 }
开发者ID:aaasekar,项目名称:store,代码行数:21,代码来源:db.cs

示例10: getDGPContacts

        public ArrayList getDGPContacts(string userId)
        {
            //Console.WriteLine("UserID: " + userId);
            try
            {
                ArrayList friendList = new ArrayList();
                itsCommand = new OdbcCommand("SELECT user FROM friends WHERE friend=\'" + userId + "\'",itsConnection);
                itsDataReader = itsCommand.ExecuteReader();
                for(int i = 0; itsDataReader.Read(); i++)
                {
            //		Console.WriteLine("Add friend: " + itsDataReader.GetString(0));
                    friendList.Add(itsDataReader.GetString(0));
                }
                itsCommand.Dispose();
                itsDataReader.Close();
                return friendList;
            }

            catch(OdbcException MyOdbcException)  //Catch any ODBC exception ..
            {
                this.handleException(MyOdbcException);
            }
            return null;
        }
开发者ID:mansehr,项目名称:DGP,代码行数:24,代码来源:Database.cs

示例11: testNameAndPassword

        public bool testNameAndPassword(string name, string password, Client client)
        {
            try
            {
                int itsInloggId;
                itsCommand = new OdbcCommand("",itsConnection);
                itsCommand.CommandText = "SELECT userID FROM users WHERE email=\'"+ name + "\'";
                itsDataReader =  itsCommand.ExecuteReader();
                if(itsDataReader.Read())
                {
                    itsInloggId = itsDataReader.GetInt32(0);
                    itsDataReader.Close();
                }
                else
                {
                    itsCommand.Dispose();
                    itsDataReader.Close();
                    return false;
                }

                itsCommand.CommandText = "SELECT password FROM users WHERE userID=\'"+ itsInloggId.ToString() + "\'";
                itsDataReader =  itsCommand.ExecuteReader();
                itsDataReader.Read();
                string databasePassword = itsDataReader.GetString(0);
                if(string.Compare(databasePassword, password, true) == 0)
                {
                    itsDataReader.Close();

                    itsCommand.CommandText = "SELECT * FROM users WHERE userID=\'"+ itsInloggId.ToString() + "\'";
                    itsDataReader =  itsCommand.ExecuteReader();
                    itsDataReader.Read();

                    client.Id = itsDataReader.GetString(0);
                    client.Email = name;
                    //client.IpNumber = itsDataReader.GetString(3);
                    client.DisplayName = itsDataReader.GetString(4);

                    itsCommand.Dispose();
                    itsDataReader.Close();
                    return true;
                }
                else
                {
                    itsCommand.Dispose();
                    itsDataReader.Close();
                    return false;
                }
            }
            catch (OdbcException MyOdbcException)//Catch any ODBC exception ..
            {
                this.handleException(MyOdbcException);
            }
            return false;
        }
开发者ID:mansehr,项目名称:DGP,代码行数:54,代码来源:Database.cs

示例12: readInt

 public int readInt( string sqlCommand)
 {
     try
     {
         int returnInt = 0;
         itsCommand = new OdbcCommand("", itsConnection);
         itsCommand.CommandText = sqlCommand;
         itsDataReader = itsCommand.ExecuteReader();
         while(itsDataReader.Read())
         {
             returnInt = itsDataReader.GetInt32(0);
         }
         itsCommand.Dispose();
         itsDataReader.Close();
         return returnInt;
     }
     catch (OdbcException MyOdbcException)//Catch any ODBC exception ..
     {
         this.handleException(MyOdbcException);
     }
     return 0;
 }
开发者ID:mansehr,项目名称:DGP,代码行数:22,代码来源:Database.cs

示例13: read

 public string read( string sqlCommand)
 {
     try
     {
         string returnString = "";
         itsCommand = new OdbcCommand("", itsConnection);
         itsCommand.CommandText = sqlCommand;
         itsDataReader = itsCommand.ExecuteReader();
         while(itsDataReader.Read())
         {
             if(returnString != "")
             {
                 returnString += "\n";
             }
             returnString += itsDataReader.GetString(0);
         }
         itsCommand.Dispose();
         itsDataReader.Close();
         return string.Copy(returnString);
     }
     catch (OdbcException MyOdbcException)//Catch any ODBC exception ..
     {
         this.handleException(MyOdbcException);
     }
     return "";
 }
开发者ID:mansehr,项目名称:DGP,代码行数:26,代码来源:Database.cs

示例14: getUserOnlineStatus

 public char getUserOnlineStatus(string id)
 {
     try
     {
         char itsChar;
         itsCommand = new OdbcCommand("",itsConnection);
         itsCommand.CommandText = "SELECT status FROM users WHERE userID=\'" + id + "\'";;
         itsDataReader =  itsCommand.ExecuteReader();
         if(itsDataReader.Read())
         {
             itsChar = itsDataReader.GetChar(0);
             itsDataReader.Close();
             itsCommand.Dispose();
             return itsChar;
         }
         else
         {
             itsDataReader.Close();
             itsCommand.Dispose();
             return 'Z';
         }
     }
     catch(OdbcException MyOdbcException)  //Catch any ODBC exception ..
     {
         this.handleException(MyOdbcException);
     }
     return 'Z';
 }
开发者ID:mansehr,项目名称:DGP,代码行数:28,代码来源:Database.cs

示例15: LoadYarnDyingApproval

        internal void LoadYarnDyingApproval(DataTable dt)
        {
            dt.Columns.Clear();
            dt.Rows.Clear();
            dt.Columns.Add("id");
            dt.Columns.Add("dcid");
            dt.Columns.Add("mapid");
            dt.Columns.Add("Select", System.Type.GetType("System.Boolean"));
            dt.Columns.Add("Invoice");
            dt.Columns.Add("DC Number");

            dt.Columns.Add("Company");
            dt.Columns.Add("Color");
            dt.Columns.Add("Rec Rolls", System.Type.GetType("System.Double"));
            dt.Columns.Add("Rec Weight", System.Type.GetType("System.Double"));

            m_dataReader = null;
            m_odbcCommand.CommandText = "SELECT     nexusGarments_YarnDyingProcess.dcno, nexusGarments_YarnDyingLog.invoiceno, nexusGarments_YarnDyingProcess.id,  nexusGarments_YarnDyingProcess.mapid, nexusGarments_YarnDyingCompany.Company, nexusGarments_PrintingColor.ColorName,  nexusGarments_YarnDyingLog.recrolls, nexusGarments_YarnDyingLog.recweight, nexusGarments_YarnDyingLog.recdate,  nexusGarments_YarnDyingLog.id AS Expr1 FROM         nexusGarments_YarnDyingLog INNER JOIN nexusGarments_YarnDyingProcess ON nexusGarments_YarnDyingLog.dcid = nexusGarments_YarnDyingProcess.id INNER JOIN nexusGarments_YarnDyingProgram ON nexusGarments_YarnDyingProcess.mapid = nexusGarments_YarnDyingProgram.id INNER JOIN nexusGarments_YarnDyingCompany ON nexusGarments_YarnDyingProgram.companyid = nexusGarments_YarnDyingCompany.id INNER JOIN nexusGarments_PrintingColor ON nexusGarments_YarnDyingProgram.colorid = nexusGarments_PrintingColor.id where  nexusGarments_YarnDyingLog.isapproved='False'";

            try
            {
                OpenDB();
                m_dataReader = m_odbcCommand.ExecuteReader(CommandBehavior.CloseConnection);
                while (m_dataReader.Read())
                {

                    dt.Rows.Add(m_dataReader["Expr1"].ToString().Trim(), m_dataReader["id"].ToString().Trim(), m_dataReader["mapid"].ToString().Trim(), "False", m_dataReader["invoiceno"].ToString().Trim(), m_dataReader["dcno"].ToString().Trim(), m_dataReader["Company"].ToString().Trim(), m_dataReader["ColorName"].ToString().Trim(), m_dataReader["recrolls"].ToString().Trim(), m_dataReader["recweight"].ToString().Trim());

                }

            }
            catch (Exception e)
            {

            }
            finally
            {
                CloseDB(1);
            }
        }
开发者ID:aaasekar,项目名称:store,代码行数:40,代码来源:db.cs


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