Tag: 连接

在每个非查询或整个连接之前打开连接?

如果我有大约2000 record ,我会进行多次插入。 哪种方法比其他方法有更好的性能? 连接每个插入。并在插入后关闭。 一个连接用于整个批量并在最后关闭连接。 那么在这种情况下连接超时呢。 备注 : 数据库是informix db。 插入约6000条记录大约需要3.5到4分钟。(第一种方法)

使用WMI和C#检测机器是在线还是离线

我在使用Win2003服务器的LAN网络中使用vs2008,winxp。 我想在winxp中安装一个应用程序来检测win2003机器是在线还是离线,如果在启动它时是否脱机。 我有这个参考,任何更多的参考,代码示例和最佳实践? http://danielvl.blogspot.com/2004/06/how-to-ping-in-c-using.html http://snipplr.com/view/2157/ping-using-wmi-pingstatus/ The popular C# Ping Utitility http://www.visualbasicscript.com/Ping-WMI-amp-NonWMI-Versions-Functions-amp-Simple-Connectivity-Monitor-m42535.aspx

entity framework – 基础提供程序在ConnectionString上失败

在使用entity framework时,我已将其拆分为自己的项目: RivWorks.Model – 包含实体模型 RivWorks.Controller – 使用实体模型并包含商业规则 RivWorks.View.Web – 该网站 RivWorks.View.Services – WCF项目 网站上的所有内容都运行良好。 我可以调用Controller并获得有效的模型。 当我从Web.Service尝试相同的事情时,我收到此错误: 错误: ConnectionString上的底层提供程序失败。 堆栈跟踪: at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) 在System.Data.EntityClient.EntityConnection..ctor(String connectionString) at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString) at System.Data.Objects.ObjectContext..ctor(String connectionString,String defaultContainerName) 在RivWorks.Model.Entities.RivFeedsEntities1..ctor(String connectionString) 在RivWorks.Model.FeedStoreReadOnly..ctor(String connectionString) 在RivWorks.Controller.ProductManager.LookupProduct(String productID,String sku,String urlRef,String env,String logPath) 我有点困惑为什么和挖掘错误日志我终于弄清楚连接字符串没有被从网站的配置文件中读取。 所以,我添加了一些代码来捕获它,并且,现在,硬编码值。喜欢: public dataObjects.NegotiateSetup LookupProduct(string productID, string sku, string urlRef, string env, string […]

我如何加入一个字符串数组,但首先删除数组中的空元素?

我使用以下内容: return string.Join(“\n”, parts); 零件有7个条目,但其中两个是空字符串“”。 如何首先删除这两个条目,然后加入剩下的五个?

如何在C#中停止一个线程?

我已经创建了一个客户端 – 服务器应用程序,并且在服务器上我希望有机会停止服务器,然后再次启动它。 问题是我无法阻止侦听Tcp连接的线程。 如何在C#中关闭线程? 谢谢。 private void KeepServer(){ while (this.connected) { tcpClient = tls.AcceptTcpClient(); Connection newConnection = new Connection(tcpClient); } }

从来自NSUrlRequest的httpcontext获取变量

对于Iphone和asp.net服务器之间的http连接“POST”,这个问题将是一个很好的教程:)我想要做的是将图像从iphone发送到Asp.net服务器; 这是我在objective-c中的uploadImagefunction: – (IBAction)uploadImage { /* turning the image into a NSData object getting the image back out of the UIImageView setting the quality to 90 */ NSData *imageData = UIImageJPEGRepresentation(image.image, 33); // setting up the URL to post to NSString *urlString = @”MyWebServiceUrl”; // setting up the request object now NSMutableURLRequest *request = [[[NSMutableURLRequest […]

在扩展方法中更改数组的大小不起作用?

所以基本上我为数组类型编写了一个小的Add扩展方法。 using System; using System.Linq; public static class Extensions { public static void Add(this T[] _self, T item) { _self = _self.Concat(new T[] { item }).ToArray(); } } public class Program { public static void Main() { string[] test = { “Hello” }; test = test.Concat(new string[] { “cruel” }).ToArray(); test.Add(“but funny”); Console.WriteLine(String.Join(” “, test) […]

SqlDataReader和SqlCommand

我有以下代码。 using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[“ConnectionString”].ConnectionString)) { connection.Open(); SqlCommand select = new SqlCommand(“SELECT RTRIM(LTRIM(PART_NO)) AS PART_NO, record FROM [RMAData].[dbo].[IMPORTING_ORDER_EDI] WHERE sessionID = ‘” + Session.SessionID + “‘”, connection); SqlDataReader reader = select.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { if (!currentPart.IsActive) { // this part is not active, set the active flag in sql to […]

如何保护ZeroMQ请求回复模式以防止潜在的消息丢失?

我正在尝试在c#应用程序和分布式python服务器之间的TCP层上实现ZeroMQ模式。 我有一个使用请求 – 回复REQ/REP模式的版本,在localhost测试时看起来相对稳定。 但是,在测试中,我调试了一些情况,我在收到回复之前意外地发送了多个请求,这显然是不可接受的。 在实践中,网络可能会有大量丢弃的数据包,我怀疑我将丢弃大量的回复和/或无法发送请求。 1)有没有办法重置REQ/REP请求 – 回复套接字 之间的连接 ? REOUTER/DEALER模式会更有意义吗? 由于这是我第一次使用ZeroMQ,我希望保持简单。 2)是否有一个良好的ZeroMQ机制来处理连接事件? 我一直在阅读“指南”,有一些关于监控连接的提及,但没有例子。 我找到了ZMonitor ,但无法在c#中触发事件。

在C#中构建文件路径的最佳实践

我正在开发一个C#项目,我必须在其中构建各种文件和文件夹的路径。 这些都在我在Web.config文件中指定的一个根文件夹下。 例如: “从我的Web.config开始:”D:\ builds \“ 传递给GetRelativePath()获取“D:\ builds \ 5.2 \ 5.2.9751” 然后传递给GetAutoSuitePath()以获取“D:\ builds \ 5.2 \ 5.2.9751 \ AutoSuite \” 然后传递给ParseBrLog,它将显示为“D:\ builds \ 5.2 \ 5.2.9751 \ AutoSuite \ AASanity.csv” 我的路径是正确的,但我只是想知道不完整路径的最佳实践。 我应该在每个文件夹的末尾添加一个“\”(“D:\ Builds \ 5.2 \”+“test.txt”),或者在我添加到路径的每个文件夹/文件的开头添加一个(“D” :\构建“+”\ 5.2“+”\ test.txt“)? 目前,我是两种方式,并且想要选择一种统一的方式。