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


C# OdbcDataReader.GetString方法代码示例

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


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

示例1: CreateForm

        public static bool CreateForm(OdbcDataReader reader, AppUser user)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);
                // Map to DB field. Need to change if db changed
                switch (name)
                {
                    case "username": user._username = reader.GetString(i);
                        break;
                    case "user_id": user._userId = reader.GetInt32(i);
                        break;
                    case "passwd": user._encodedPassword = reader.GetString(i);
                        break;
                    case "firstname": user._firstname = reader.GetString(i);
                        break;
                    case "surname": user._surname = reader.GetString(i);
                        break;
                    case "role_id": user._roleId = reader.GetInt32(i);
                        break;
                    case "branch_id": user._branchID = reader.GetInt32(i);
                        break;
                    case "is_valid": user._isValid = reader.GetInt32(i) > 0 ? true : false;
                        break;

                    // helper info
                    case "branch_name": user._branchName = reader.GetString(i);
                        break;

                }
            }
            return reader.HasRows;
        }
开发者ID:nettatata,项目名称:btsman,代码行数:34,代码来源:AppUser.cs

示例2: CreateForm

        public static bool CreateForm(OdbcDataReader reader, Room room)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "room_id": room._roomID = reader.GetInt32(i);
                                      break;
                    case "branch_id": room._branchID = reader.GetInt32(i);
                                      break;
                    case "name": room._name = reader.GetString(i);
                                      break;
                    case "seat_no": room._seatNo = reader.GetInt32(i);
                                      break;
                    case "img": room._img = reader.GetString(i);
                                      break;
                    case "description": room._description = reader.GetString(i);
                                      break;

                    // helper info
                    case "branch_name": room._branchName = reader.GetString(i);
                                      break;

                }
            }
            return reader.HasRows;
        }
开发者ID:nettatata,项目名称:btsman,代码行数:30,代码来源:Room.cs

示例3: 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

示例4: 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

示例5: 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

示例6: read

        public QuestionEntity read(OdbcDataReader reader)
        {
            var res = new QuestionEntity();
            res.id = reader.GetInt32(0);
            res.ans = reader.GetString(2);


            var choicejson = reader.GetString(3);
            var decoder = new JavaScriptSerializer();
            res.choices = decoder.Deserialize< ArrayList >(choicejson);

            res.imageURL = reader.GetString(4);
            res.statement = reader.GetString(5);
            res.type = getTypeString( reader.GetInt32(1) );

            return res;

        }
开发者ID:funtion,项目名称:exam-aspx,代码行数:18,代码来源:QuestionModel.cs

示例7: CreateForm

        public static bool CreateForm(OdbcDataReader reader, Branch branch)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "branch_id": branch._branchID = reader.GetInt32(i);
                                      break;
                    case "branch_name": branch._branchName = reader.GetString(i);
                                      break;
                    case "branch_code": branch._branchCode = reader.GetString(i);
                                      break;
                    case "address": branch._address = reader.GetString(i);
                                      break;
                    case "tel": branch._tel = reader.GetString(i);
                                      break;
                    case "img": branch._img = reader.GetString(i);
                                      break;
                    case "supervisor": branch._supervisor = reader.GetString(i);
                                      break;
                }
            }
            return reader.HasRows;
        }
开发者ID:nettatata,项目名称:btsman,代码行数:27,代码来源:Branch.cs

示例8: CreateForm

        public static bool CreateForm(OdbcDataReader reader, Teacher teacher)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "teacher_id": teacher._teacherID = reader.GetInt32(i);
                                      break;
                    case "sex": teacher._sex = reader.GetString(i);
                                      break;
                    case "addr": teacher._addr = reader.GetString(i);
                                      break;
                    case "tel": teacher._tel = reader.GetString(i);
                                      break;
                    case "email": teacher._email = reader.GetString(i);
                                      break;
                    case "birthday":
                        teacher._birthday = new DateTime(reader.GetDate(i).Ticks);
                                      break;
                    case "firstname": teacher._firstname = reader.GetString(i);
                                      break;
                    case "surname": teacher._surname = reader.GetString(i);
                                      break;
                    case "citizen_id": teacher._citizenID = reader.GetString(i);
                                      break;
                    case "image": teacher._img = reader.GetString(i);
                                      break;
                    case "subject": teacher._subject = reader.GetString(i);
                                      break;
                    case "is_active": teacher._isActive = reader.GetInt32(i) > 0 ? true : false;
                                      break;

                }
            }
            return reader.HasRows;
        }
开发者ID:nettatata,项目名称:btsman,代码行数:39,代码来源:Teacher.cs

示例9: CreateForm

        public static bool CreateForm(OdbcDataReader reader, PaidGroup paidGroup)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);
                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "paid_group_id": paidGroup._paidGroupID = reader.GetInt32(i);
                                      break;
                    case "name": paidGroup._name = reader.GetString(i);
                                      break;
                    case "current_round": paidGroup._currentRound = reader.GetInt32(i);
                                      break;
                    case "rate_info": paidGroup._rawRateInfo = reader.GetString(i);
                                      paidGroup._rateInfo = PaidRateInfo.Parse(paidGroup._rawRateInfo);
                                      break;

                    // helper info

                }
            }
            return reader.HasRows;
        }
开发者ID:nettatata,项目名称:btsman,代码行数:24,代码来源:PaidGroup.cs

示例10: CreateForm

        public static bool CreateForm(OdbcDataReader reader, Role role)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "name": role._name = reader.GetString(i);
                                      break;
                    case "role_id": role._roleId = reader.GetInt32(i);
                                      break;
                }
            }
            return reader.HasRows;
        }
开发者ID:nettatata,项目名称:btsman,代码行数:17,代码来源:Role.cs

示例11: GetTicketInfo

 public void GetTicketInfo()
 {
     ticketNum = int.Parse(reader.ReadLine());//get the ticket number you want to handle
     command = "SELECT T.Number, T.Issue_Date,I.Assigned, I.JobDone, I.Status, I.Sequence, I.Due_Date, I.Requirements, I.Attachment " +
         "FROM Ticket_Information AS I, Ticket AS T WHERE T.Number=" + ticketNum + " AND T.Number=I.Number AND I.Assigned='"+userName+"'";//name,email,pass
     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 ##
         }
         writer.WriteLine(line);
         writer.Flush();
     }
     writer.WriteLine(".");//sending the end of tickets info
     writer.Flush();
 }
开发者ID:hsnamr,项目名称:ARS-Server,代码行数:20,代码来源:HandleMember.cs

示例12: UpdateSuccessor

 public void UpdateSuccessor()
 {
     //Updating the Status of the succeding sequence
     command = "SELECT Sequence FROM Ticket_Information WHERE Number=" + ticketNum + " AND Assigned='" + userName + "'";
     sqlCommand = new OdbcCommand(command, dbConn);
     dbReader = sqlCommand.ExecuteReader();
     dbReader.Read();
     int seq = int.Parse(dbReader.GetString(0));
     command = "SELECT MAX(Sequence) FROM Ticket_Information WHERE Number=" + ticketNum;
     sqlCommand = new OdbcCommand(command, dbConn);
     dbReader = sqlCommand.ExecuteReader();
     dbReader.Read();
     int seq2 = int.Parse(dbReader.GetString(0));
     if (seq < seq2)// means there are successors
     {
         command = "SELECT Assigned FROM Ticket_Information WHERE Number=" + ticketNum+" AND Sequence="+(++seq);
         sqlCommand = new OdbcCommand(command, dbConn);
         dbReader = sqlCommand.ExecuteReader();
         dbReader.Read();
         successor = dbReader.GetString(0);
         string[] tokens = allFiles.Split('#');
         Directory.CreateDirectory(successor + "/" + ticketNum);
         for (int k = 0; k < tokens.Length; k++)
         {
             try
             {
                 File.Copy((userName + "/" + ticketNum + "/" + tokens[k]), (successor + "/" + ticketNum + "/" + tokens[k]),true);
             }
             catch(Exception ww)
             {
                 Console.WriteLine(ww);//gives an exception but still works !!!!
             }
         }
         command = " Update Ticket_Information SET Status='Assigned' , Attachment= Attachment + '" + allFiles + "' WHERE  Number=" + ticketNum + " AND Sequence =" + seq;//sequece has been updated earlier
         sqlCommand = new OdbcCommand(command, dbConn);
         sqlCommand.ExecuteNonQuery();// even if no one preceeding
     }
 }
开发者ID:hsnamr,项目名称:ARS-Server,代码行数:38,代码来源:HandleMember.cs

示例13: HandleConnection

        public void HandleConnection(Object state)
        {
            try
            {
                ns = new NetworkStream(client);
                reader = new StreamReader(ns);
                writer = new StreamWriter(ns);
                connections++;
                Console.WriteLine("New client accepted: {0} active connections", connections);
                writer.WriteLine("Welcome to my server");
                writer.Flush();
                line = null;
                try
                {
                    line = reader.ReadLine();
                    if (line.Trim().Equals("Auth"))
                    {
                        userName = reader.ReadLine();
                        password = reader.ReadLine();

                        string auth = "SELECT * FROM User_Information WHERE Name='" + userName +
                            "' AND Password='" + password + "'";

                        sqlCommand = new OdbcCommand(auth, dbConn);
                        sqlCommand.ExecuteNonQuery();
                        dbReader = sqlCommand.ExecuteReader();
                        if (dbReader.Read())
                        {
                            writer.WriteLine("Auth OK");
                            writer.Flush();
                            writer.WriteLine("Welcome " + dbReader.GetString(3));
                            writer.Flush();
                            if (dbReader.GetString(3).Equals("Leader"))
                                new HandleLeader(dbConn, ns, reader, writer, userName);
                            else if (dbReader.GetString(3).Equals("Member"))
                                new HandleMember(dbConn, ns, reader, writer, userName);
                            else if (dbReader.GetString(3).Equals("System"))
                                new HandleSystem(dbConn, reader, writer);
                        }
                        else
                            writer.WriteLine("Auth not OK");
                    }
                    else if (line.Trim().Equals("Quit"))
                        goto Skip;
                }
                catch (SocketException)
                {
                    writer.WriteLine("Error"); writer.Flush();
                }
                catch
                {
                }
                Skip:
                client.Close();
                ns.Close();
                dbConn.Close();
                connections--;
                Console.WriteLine("Client disconnected: {0}active connections", connections);
            }
            catch (Exception)
            {
                connections--;
                Console.WriteLine("Client disconnected: {0} active connections", connections);
            }
        }
开发者ID:hsnamr,项目名称:ARS-Server,代码行数:65,代码来源:RemedyServer.cs

示例14: GetProfileInfoFromReader

        //
        // GetProfileInfoFromReader
        //  Takes the current row from the OdbcDataReader
        // and populates a ProfileInfo object from the values.
        //
        private ProfileInfo GetProfileInfoFromReader(OdbcDataReader reader)
        {
            string username = reader.GetString(0);

            DateTime lastActivityDate = new DateTime();
            if (reader.GetValue(1) != DBNull.Value)
                lastActivityDate = reader.GetDateTime(1);

            DateTime lastUpdatedDate = new DateTime();
            if (reader.GetValue(2) != DBNull.Value)
                lastUpdatedDate = reader.GetDateTime(2);

            bool isAnonymous = reader.GetBoolean(3);

            // ProfileInfo.Size not currently implemented.
            ProfileInfo p = new ProfileInfo(username,
                isAnonymous, lastActivityDate, lastUpdatedDate, 0);

            return p;
        }
开发者ID:grrizzly,项目名称:3D-Repository,代码行数:25,代码来源:MysqlProfileProvider.cs

示例15: GetUserFromReader

        //
        // GetUserFromReader
        //    A helper function that takes the current row from the OdbcDataReader
        // and hydrates a MembershiUser from the values. Called by the
        // MembershipUser.GetUser implementation.
        //
        private MembershipUser GetUserFromReader(OdbcDataReader reader)
        {
            object providerUserKey = reader.GetValue(0);
            string username = reader.GetString(1);
            string email = reader.GetString(2);

            string passwordQuestion = "";
            if (reader.GetValue(3) != DBNull.Value)
                passwordQuestion = reader.GetString(3);

            string comment = "";
            if (reader.GetValue(4) != DBNull.Value)
                comment = reader.GetString(4);

            bool isApproved = reader.GetBoolean(5);
            bool isLockedOut = reader.GetBoolean(6);
            DateTime creationDate = reader.GetDateTime(7);

            DateTime lastLoginDate = new DateTime();
            if (reader.GetValue(8) != DBNull.Value)
                lastLoginDate = reader.GetDateTime(8);

            DateTime lastActivityDate = reader.GetDateTime(9);
            DateTime lastPasswordChangedDate = reader.GetDateTime(10);

            DateTime lastLockedOutDate = new DateTime();
            if (reader.GetValue(11) != DBNull.Value)
                lastLockedOutDate = reader.GetDateTime(11);

            MembershipUser u = new MembershipUser((this.Name == null) ? "SimpleMysqlMembershipProvider" : this.Name,
                                                  username,
                                                  providerUserKey,
                                                  email,
                                                  passwordQuestion,
                                                  comment,
                                                  isApproved,
                                                  isLockedOut,
                                                  creationDate,
                                                  lastLoginDate,
                                                  lastActivityDate,
                                                  lastPasswordChangedDate,
                                                  lastLockedOutDate);

            return u;
        }
开发者ID:windrobin,项目名称:3D-Repository,代码行数:51,代码来源:MysqlMembershipProvider.cs


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