本文整理汇总了C#中Connection类的典型用法代码示例。如果您正苦于以下问题:C# Connection类的具体用法?C# Connection怎么用?C# Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connection类属于命名空间,在下文中一共展示了Connection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
Menu menu = Master.FindControl("NavigationMenu") as Menu;
menu.Items[2].ChildItems[0].ChildItems.RemoveAt(1);
if (Session.Contents["rol"].ToString().Equals("DSTADM"))
Response.Redirect("../Default.aspx");
Connection conexion = new Connection();
string query = String.Empty;
SqlDataSource1.ConnectionString = conexion.getConnectionString();
if (Session.Contents["rol"].ToString().Equals("KCPADM"))
query = String.Format("SELECT USER_ID, USER_NAME, STATUS, E_MAIL FROM USUARIOS AS U WHERE USER_ID <> '{0}' AND ID_COUNTRY = '{1}' AND 0 = (SELECT count(Kam.KAM_NAME) from Kam where Kam.KAM_ID = U.USER_ID AND Kam.KAM_ACTIVE = 1)",
Session.Contents["userid"].ToString(), conexion.getUserCountry(Session.Contents["userid"].ToString()));
else if (Session.Contents["rol"].ToString().Equals("KCPCCR"))
query = String.Format("SELECT USER_ID, USER_NAME, STATUS, E_MAIL FROM USUARIOS WHERE USER_ID <> '{0}' AND ID_COUNTRY = '{1}' AND (ID_ROL <> 'KCPADM' AND ID_ROL <> 'KCPCCR')",
Session.Contents["userid"].ToString(), conexion.getUserCountry(Session.Contents["userid"].ToString()));
SqlDataSource1.SelectCommand = query;
SqlDataSource1.ConflictDetection = ConflictOptions.CompareAllValues;
}
catch (Exception error)
{
RadAjaxManager1.ResponseScripts.Add(String.Format("errorEnvio('{0}');", error.Message));
}
}
开发者ID:Eliazar,项目名称:Dispenser_Tracking,代码行数:30,代码来源:Editar_Usuario.aspx.cs
示例17: Add
public static void Add(
Connection connection,
NetworkMessage outMessage,
Location fromLocation,
Location toLocation
)
{
if (fromLocation.Y > toLocation.Y)
{ // north, for old x
outMessage.AddByte((byte)ServerPacketType.MapSliceNorth);
AddMapDescription(connection, outMessage, fromLocation.X - 8, toLocation.Y - 6, toLocation.Z, 18, 1);
}
else if (fromLocation.Y < toLocation.Y)
{ // south, for old x
outMessage.AddByte((byte)ServerPacketType.MapSliceSouth);
AddMapDescription(connection, outMessage, fromLocation.X - 8, toLocation.Y + 7, toLocation.Z, 18, 1);
}
if (fromLocation.X < toLocation.X)
{ // east, [with new y]
outMessage.AddByte((byte)ServerPacketType.MapSliceEast);
AddMapDescription(connection, outMessage, toLocation.X + 9, toLocation.Y - 6, toLocation.Z, 1, 14);
}
else if (fromLocation.X > toLocation.X)
{ // west, [with new y]
outMessage.AddByte((byte)ServerPacketType.MapSliceWest);
AddMapDescription(connection, outMessage, toLocation.X - 8, toLocation.Y - 6, toLocation.Z, 1, 14);
}
}
开发者ID:henriqueuller,项目名称:sharpot,代码行数:29,代码来源:MapSlicePacket.cs
示例18: Connect
public override async Task<bool> Connect(Connection newConnection)
{
var deviceInfo = newConnection.Source as DeviceInformation;
if (deviceInfo != null)
{
this.service = await SerialDevice.FromIdAsync(deviceInfo.Id);
if (this.service == null)
{
return false;
}
this.service.BaudRate = 115200;
this.service.StopBits = SerialStopBitCount.One;
this.service.Handshake = SerialHandshake.None;
this.service.DataBits = 8;
this.service.ReadTimeout = TimeSpan.FromSeconds(5);
this.service.WriteTimeout = TimeSpan.FromSeconds(5);
this.service.IsDataTerminalReadyEnabled = false;
return this.InstrumentSocket(this.service.InputStream, this.service.OutputStream);
}
return false;
}
开发者ID:CRDeveloper,项目名称:virtual-shields-universal,代码行数:25,代码来源:USB.cs
示例19: CollectionMetadata
/// <summary>
/// Initializes a new instance of the <see cref="CollectionMetadata"/> class.
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <param name="databaseName">Name of the database.</param>
/// <param name="collectionName">The name.</param>
/// <param name="connection">The connection.</param>
internal CollectionMetadata(MongoConfiguration configuration, string databaseName, string collectionName, Connection connection)
{
//Todo: Add public constrcutors for users to call
_fullName = databaseName + "." + collectionName;
_name = collectionName;
_database = new MongoDatabase(configuration, connection, databaseName);
}
开发者ID:nisbus,项目名称:mongodb-csharp,代码行数:14,代码来源:CollectionMetadata.cs
示例20: CheckIn
public void CheckIn(Connection value)
{
lock (_ConnectionQueue)
{
_ConnectionQueue.Enqueue(value);
}
}
开发者ID:jcustenborder,项目名称:voldemort,代码行数:7,代码来源:ConnectionPool.cs
注:本文中的Connection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论