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


C# Connection类代码示例

本文整理汇总了C#中Connection的典型用法代码示例。如果您正苦于以下问题:C# Connection类的具体用法?C# Connection怎么用?C# Connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: FindUserEmailID

 public bool FindUserEmailID(int userEmailID)
 {
     string sql = string.Format("SELECT * FROM UserEmails WHERE UserEmailID = '{0}' ", userEmailID);
     using(Connection cn = new Connection())
     {
         using (SqlCommand cmd = new SqlCommand())
         {
             try
             {
                 cmd.Connection = cn.SqlConnection;
                 cmd.CommandText = sql;
                 int recordsAffected = cmd.ExecuteNonQuery();
                 SqlDataReader reader = cmd.ExecuteReader();
                 if (reader.HasRows)
                 {
                     while (reader.Read())
                     {
                         //UserID = (int)reader["UserID"];
                         //loginName = reader["LoginName"].ToString();
                     }
                     return true;
                 }
                 else
                     return false;
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(ex.Message);
                 return false;
             }
         }
     }
     //return true;
 }
开发者ID:MagnusTiberius,项目名称:GigaBoom,代码行数:34,代码来源:UserEmail.cs

示例2: InsertUpdate

 //insert update
 public Entities.KhoHang InsertUpdate(Entities.KhoHang kh1)
 {
     Entities.KhoHang k = new Entities.KhoHang();
     try
     {
         kh = new Constants.KhoHang();
         Sql = new Constants.Sql();
         string sql = Sql.InsertUpdateKhoHang;
         Connection conn = new Connection();
         SqlConnection cn = conn.openConnection();
         SqlCommand cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add(kh.HanhDong, SqlDbType.NVarChar, 20).Value = kh1.HanhDong;
         cmd.Parameters.Add(kh.KhoHangID, SqlDbType.Int).Value = kh1.KhoHangID;
         cmd.Parameters.Add(kh.MaKho, SqlDbType.VarChar, 20).Value = kh1.MaKho;
         cmd.Parameters.Add(kh.TenKho, SqlDbType.NVarChar, 200).Value = kh1.TenKho;
         cmd.Parameters.Add(kh.DiaChi, SqlDbType.NVarChar, 200).Value = kh1.DiaChi;
         cmd.Parameters.Add(kh.DienThoai, SqlDbType.NVarChar, 200).Value = kh1.DienThoai;
         cmd.Parameters.Add(kh.MaNhanVien, SqlDbType.NVarChar, 200).Value = kh1.MaNhanVien;
         cmd.Parameters.Add(kh.GhiChu, SqlDbType.NVarChar, 100).Value = kh1.GhiChu;
         cmd.Parameters.Add(kh.Deleted, SqlDbType.Bit).Value = kh1.Deleted;
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         while (dr.Read())
         {
             k.GhiChu = dr[0].ToString();
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); k.GhiChu = null; }
     return k;
 }
开发者ID:mrk29vn,项目名称:vna-accounting,代码行数:31,代码来源:KhoHang.cs

示例3: GetDataByID

        public Recordset GetDataByID(Connection cn, int id)
        {
            string sql = "ad_GetCategoryByID " + id;
            Recordset rs = conn.Execute(sql, cn);

            return rs;
        }
开发者ID:andyyo88,项目名称:myproject,代码行数:7,代码来源:Category.cs

示例4: DCC

 internal DCC(ServerConnection creatorsServerConnection, Connection Parent)
     : base(creatorsServerConnection)
 {
     chat = new DCCChatContainer(creatorsServerConnection);
     transfer = new DCCTransferContainer(creatorsServerConnection);
     parent = Parent;
 }
开发者ID:dab85,项目名称:irc-sharp,代码行数:7,代码来源:DCC.cs

示例5: BinaryDecoder

 public BinaryDecoder(Connection conn)
 {
     Connection = conn;
     // some messages have multiple blank lines between the header & message body
     while(conn.PeekLine() == string.Empty)
         conn.ReadLine();
 }
开发者ID:strider-,项目名称:NntpClient,代码行数:7,代码来源:BinaryDecoder.cs

示例6: SetUp

        public override void SetUp()
        {
            this.connection = (Connection) CreateConnection();
            this.connection.RedeliveryPolicy = GetRedeliveryPolicy();

            this.counter = 0;
        }
开发者ID:ThorTech,项目名称:apache-nms,代码行数:7,代码来源:MessageListenerRedeliveryTest.cs

示例7: Handle

        public override void Handle(Connection connection)
        {
            var account = connection.Session.Account;
            var notification = new Notification();

            notification.UserId = account.Id;
            notification.Regex = new Regex(RegexPattern);
            notification.DeviceToken = DeviceToken;

            if (Program.NotificationManager.Exists(DeviceToken))
            {
                notification.Save();
            }
            else
            {
                if (Program.NotificationManager.FindWithId(account.Id).Count() < 5)
                {
                    notification.Insert();
                }
                else
                {
                    connection.SendSysMessage("You may only have 5 devices registered for push notifications.");
                    return;
                }
            }

            Program.NotificationsDirty = true;

            var notificationSubscription = new NotificationSubscription();
            notificationSubscription.DeviceToken = DeviceToken;
            notificationSubscription.RegexPattern = RegexPattern;
            notificationSubscription.Registered = true;

            connection.Send(notificationSubscription);
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:35,代码来源:NotificationSubscriptionRequest.cs

示例8: NodePingInfo

 public NodePingInfo(IConnection con, string nodeName = null)
 {
     Connection = new Connection(con);
     NextPingDate = DateTime.Now;
     IsPinged = false;
     NodeName = nodeName;
 }
开发者ID:supcry,项目名称:Plex,代码行数:7,代码来源:NodePingInfo.cs

示例9: SeekerData

 public SeekerData(SeekerData original, Connection connection, float gScore, float hScore)
 {
     m_Path = new List<Connection> (original.Path);
     m_Path.Add (connection);
     m_GScore = original.GScore + gScore;
     m_HScore = original.HScore + hScore;
 }
开发者ID:Joelone,项目名称:Path,代码行数:7,代码来源:SeekerData.cs

示例10: sp_ThongTinCongTy

        /// <summary>
        /// lay bang cong ty
        /// </summary>
        /// <param name="ct"></param>
        /// <returns></returns>
        public Entities.ThongTinCongTy sp_ThongTinCongTy(Entities.TruyenGiaTri ct)
        {
            Entities.ThongTinCongTy banghi = new Entities.ThongTinCongTy();
            try
            {
                string sql = "exec sp_ThongTinCongTy @MaCongTy";
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add("MaCongTy", SqlDbType.VarChar, 20).Value = ct.Giatritruyen;
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                ArrayList arr = new ArrayList();
                while (dr.Read())
                {

                    banghi.MaCongTy = dr[0].ToString();
                    banghi.TenCongTy = dr[1].ToString();
                    banghi.DiaChi = dr[2].ToString();
                    banghi.SoDienThoai = dr[3].ToString();
                    banghi.Email = dr[4].ToString();
                    banghi.Website = dr[5].ToString();
                    banghi.Fax = dr[6].ToString();
                }
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); banghi = null; }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return banghi;
        }
开发者ID:mrk29vn,项目名称:vna-accounting,代码行数:39,代码来源:ThongTinCongTy.cs

示例11: GetTarget_CategoriesToTransfer

 public static Dictionary<string, Category> GetTarget_CategoriesToTransfer(Connection connection)
 {
     var transferCategories =
         connection.ThisSideCategories
                   .Where(
                       tCat => tCat.NativeCategoryDomainName == "AaltoGlobalImpact.OIP" &&
                               tCat.NativeCategoryObjectName == "Category")
                   .ToArray();
     CategoryCollection categoryCollection = CategoryCollection.RetrieveFromOwnerContent(
         InformationContext.CurrentOwner, "MasterCollection");
     var sourceCategoryDict = categoryCollection.CollectionContent.ToDictionary(cat => cat.ID);
     var sourceCategoryList = categoryCollection.CollectionContent;
     var childrenInclusiveSourceIDs = connection.CategoryLinks.Where(catLink => catLink.LinkingType == TheBall.Interface.Category.LINKINGTYPE_INCLUDECHILDREN).Select(catLink => catLink.SourceCategoryID).ToArray();
     var childrenInclusiveIDs = transferCategories
         .Where(tCat => childrenInclusiveSourceIDs.Contains(tCat.ID))
         .Select(tCat => tCat.NativeCategoryID).OrderBy(str => str)
         .ToList();
     var exactMatchSourceIDs = connection.CategoryLinks.Where(catLink => catLink.LinkingType == TheBall.Interface.Category.LINKINGTYPE_ONE).Select(catLink => catLink.SourceCategoryID).ToArray();
     var exactMatchIDs = transferCategories
         .Where(tCat => exactMatchSourceIDs.Contains(tCat.ID))
         .Select(tCat => tCat.NativeCategoryID).OrderBy(str => str)
         .ToList();
     var result =
         sourceCategoryList
             .Where(cat => matchesOrParentMatches(cat, exactMatchIDs, childrenInclusiveIDs, sourceCategoryDict))
             .ToArray();
     return result.ToDictionary(cat => cat.ID);
 }
开发者ID:kallex,项目名称:Caloom,代码行数:28,代码来源:PickCategorizedContentToConnectionImplementation.cs

示例12: SendingCommandObjectSetsCommandOnBus

        public void SendingCommandObjectSetsCommandOnBus()
        {
            var messageBus = new Mock<IMessageBus>();
            var counters = new Mock<IPerformanceCounterWriter>();
            Message message = null;
            messageBus.Setup(m => m.Publish(It.IsAny<Message>())).Returns<Message>(m =>
            {
                message = m;
                return TaskAsyncHelper.Empty;
            });

            var serializer = new JsonNetSerializer();
            var traceManager = new Mock<ITraceManager>();
            var connection = new Connection(messageBus.Object,
                                            serializer,
                                            "signal",
                                            "connectonid",
                                            new[] { "a", "signal", "connectionid" },
                                            new string[] { },
                                            traceManager.Object,
                                            counters.Object);

            connection.Send("a", new Command
            {
                Type = CommandType.AddToGroup,
                Value = "foo"
            });

            Assert.NotNull(message);
            Assert.True(message.IsCommand);
            var command = serializer.Parse<Command>(message.Value);
            Assert.Equal(CommandType.AddToGroup, command.Type);
            Assert.Equal("foo", command.Value);
        }
开发者ID:arjunshetty2020,项目名称:SignalR,代码行数:34,代码来源:ConnectionFacts.cs

示例13: JDBCCategoryDataset

 public JDBCCategoryDataset(string url, string driverName, string user, string passwd)
 {
   JDBCCategoryDataset jdbcCategoryDataset = this;
   this.transpose = true;
   Class.forName(driverName, JDBCCategoryDataset.__\u003CGetCallerID\u003E());
   this.connection = DriverManager.getConnection(url, user, passwd, JDBCCategoryDataset.__\u003CGetCallerID\u003E());
 }
开发者ID:NALSS,项目名称:SmartDashboard.NET,代码行数:7,代码来源:JDBCCategoryDataset.cs

示例14: getMensalistabyId_cliente

        public Mensalista getMensalistabyId_cliente(int id_cliente)
        {
            Mensalista returnMensalista = null;

            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "select * from Mensalistas m inner join Clientes c on m.Id_cliente = c.Id_Cliente where m.Id_cliente = " + id_cliente + " ";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            if (reader.Read())
            {
                while (reader.Read())
                {
                    returnMensalista.id_mensalista = Int32.Parse(string.Format("{0}", reader[0]));
                    returnMensalista.id_cliente = Int32.Parse(string.Format("{0}", reader[1]));
                    returnMensalista.nome_cliente = string.Format("{0}", reader[4]);
                    returnMensalista.data_termino = string.Format("{0}", reader[2]);
                }
            }

            return returnMensalista;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:27,代码来源:mensalistaDAO.cs

示例15: buscar

        public List<Mensalista> buscar(String nomeCliente)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "SELECT * FROM Mensalistas m INNER JOIN Clientes c ON m.Id_cliente = c.Id_Cliente WHERE c.Nome like '%"+ nomeCliente +"%'";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            List<Mensalista> listaMensalistas = new List<Mensalista>();

            while (reader.Read())
            {
                Mensalista mensalista = new Mensalista();
                mensalista.id_mensalista = Int32.Parse(string.Format("{0}", reader[0]));
                mensalista.id_cliente = Int32.Parse(string.Format("{0}", reader[1]));

                Cliente cliente = new Cliente();
                cliente.nome = string.Format("{0}", reader[4]);

                mensalista.nome_cliente = cliente.nome;
                mensalista.data_termino = string.Format("{0}", reader[2]);

                listaMensalistas.Add(mensalista);
            }
            con.closeConnection();
            return listaMensalistas;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:31,代码来源:mensalistaDAO.cs


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