本文整理汇总了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;
}
示例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;
}
示例3: GetDataByID
public Recordset GetDataByID(Connection cn, int id)
{
string sql = "ad_GetCategoryByID " + id;
Recordset rs = conn.Execute(sql, cn);
return rs;
}
示例4: DCC
internal DCC(ServerConnection creatorsServerConnection, Connection Parent)
: base(creatorsServerConnection)
{
chat = new DCCChatContainer(creatorsServerConnection);
transfer = new DCCTransferContainer(creatorsServerConnection);
parent = Parent;
}
示例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();
}
示例6: SetUp
public override void SetUp()
{
this.connection = (Connection) CreateConnection();
this.connection.RedeliveryPolicy = GetRedeliveryPolicy();
this.counter = 0;
}
示例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);
}
示例8: NodePingInfo
public NodePingInfo(IConnection con, string nodeName = null)
{
Connection = new Connection(con);
NextPingDate = DateTime.Now;
IsPinged = false;
NodeName = nodeName;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}