
c#
wthorse
这个作者很懒,什么都没留下…
展开
-
关于连接远程sqlserver命令的一些帮助
--创建链接服务器exec sp_addlinkedserver wt_lnk,,SQLOLEDB,192.168.*.*exec sp_addlinkedsrvlogin wt_lnk,false,null,sa,wthorsego--查询示例select * from wt_lnk.news.dbo.news--导入示例select * into sna原创 2006-08-30 13:43:00 · 1874 阅读 · 0 评论 -
日期时间星期的获得
//本周的周一public static DateTime CalculateFirstDateOfWeek(DateTime someDate) { someDate=Convert.ToDateTime(someDate.ToShortDateString()); int i = someDate.DayOfWeek - DayOfWeek.Monday; if (i原创 2006-06-19 11:33:00 · 842 阅读 · 0 评论 -
c#.net画曲线图(坐标)
using System.Drawing.Imaging;using System.Drawing.Drawing2D; //数据/月份 public ArrayList arrData=new ArrayList(); public ArrayList arrMonth=new ArrayList(); //定义幕布高宽 private int iCanvasWidth=40原创 2006-06-29 09:04:00 · 4189 阅读 · 4 评论 -
读图片的绝对地址
由于很多网页代码里面图片是相对路径。在取图片的时候就需要绝对路径。这时候就可通过当前页面的url与图片的相对路径来拼凑。而大部分条件就根据相对路径来判断,读其前2个字符。分为 ./,../,/,image/,等一些情况其中关键地方在判断..的时候,url往左移一个/ ***/的位置,而图片相对路径往右移动../位置。这样问题就解决了,当然还有其他细节,那就慢慢细心调了。我猜测应原创 2006-11-15 15:06:00 · 1234 阅读 · 0 评论 -
关于对异常程序处理的监视程序
由于在程序开发中,很多问题是无法预计的,不管什么软件都会有bug,连windows也会死机,何况自己的程序,今天花两个小时给自己的容易出问题的程序编一个监视程序。方案有很多,比如,利用wmi消息传送,利用信号量控制等。我是根据自己程序特点,在我多线程里,当出现问题时候,首先在数据库某项操作时间上就会出现特征,于是我就根据特征判断程序有无异常,发生异常时候先利用process去关闭,再打开,这样简单原创 2006-11-11 11:16:00 · 951 阅读 · 0 评论 -
短文件名(经常用到)
public static string ToShortPathName(string longName) { StringBuilder shortNameBuffer = new StringBuilder(256); int bufferSize = shortNameBuffer.Capacity; int result = GetShortPathName(longNa原创 2006-08-02 15:01:00 · 1044 阅读 · 0 评论 -
xml图片的生成
string xmlFileName=strTempXml; XmlTextWriter xw=new XmlTextWriter(xmlFileName,Encoding.UTF8); xw.WriteStartDocument(); xw.WriteStartElement("image"); xw.WriteString(photo); xw.Writ原创 2006-08-03 10:06:00 · 2906 阅读 · 0 评论 -
文件编码读出
Encoding encode=Encoding.GetEncoding("GB2312"); reader=new StreamReader(jpgFile,encode); string content=reader.ReadToEnd();原创 2006-08-02 12:37:00 · 638 阅读 · 0 评论 -
textBox的一点点小技巧
this.textBox1.Text+="暂无新记录.../r/n"; this.textBox1.Focus(); this.textBox1.Select(this.textBox1.Text.Length,0); this.textBox1.ScrollToCaret(); 保持滚动条的位置在最下面原创 2006-08-29 13:56:00 · 865 阅读 · 0 评论 -
进程里启动关闭程序
private void CloseApp(string appName) { try { System.Diagnostics.Process[] myProcesses; myProcesses =System.Diagnostics.Process.GetProcessesByName(appName); foreach (System.Diagnostics.原创 2006-12-20 14:01:00 · 1009 阅读 · 0 评论 -
防止应用程序多次执行(在进程里只一个)
[STAThread] static void Main() { bool isCreate; Mutex mutex=new Mutex(true,"JNR3Lead",out isCreate); if(isCreate) { Application.Run(new Form1()); mutex.ReleaseMutex(); } }原创 2006-08-29 14:32:00 · 1153 阅读 · 0 评论 -
c#里的解压缩
/// /// 功能:解压缩 /// 作者:wthrose /// /// /// public void GZipDecompress(string FileName, string OutFileName) { FileStream infile, outfile;原创 2007-01-05 16:15:00 · 871 阅读 · 0 评论 -
转义字符列表
转义序列 字符说明 产生的字符 //u002E 点 . //u0024 美元符原创 2008-03-24 11:25:00 · 1010 阅读 · 0 评论 -
读取手机型号
String user_agent=request.getHeader("User-Agent"); String user_agent=Request.Headers["User-Agent"];原创 2009-04-22 20:27:00 · 787 阅读 · 0 评论 -
c#.net 下的邮件发送(含附件)
string aa=this.dbpath.Replace("////","//").Replace("//","////"); MailMessage mailObj = new MailMessage(); // 设置邮件的发送及接收地址 mailObj.From =wthorse@gmail.com //mailObj原创 2006-06-13 15:03:00 · 2565 阅读 · 0 评论 -
c#.net 中压缩access并且更名
dbpath=Application.ExecutablePath; dbpath=dbpath.Substring(0,dbpath.LastIndexOf("//")+1); dbpath=dbpath+//asd.mdb; ConnectString="Provider = Microsoft.Jet.OLEDB.4.0;Data Source ="+dbpath;//压原创 2006-06-13 09:09:00 · 1225 阅读 · 0 评论 -
今天用笨方法合并结构不同的库,郁闷
SqlConnection conn = DB.createConn(); string exec1 = "select book_id,isbn,book_name,author,0 as notepad from t_book"; string exec2 = "select * from t_book_merge"; DataSet ds = ne原创 2006-06-06 23:12:00 · 726 阅读 · 0 评论 -
b/s下新闻首页调用webservice方案参考
首先在webservice中设置好WebMethod,即selectuserpwd(exec,i,j)方法然后在客户代码中:string exec="select * from userpwd"; ds=new DataSet(); ds=mbi.selectuserpwd(exec,1,10); dt=new DataTable(); col=new DataColu原创 2006-04-23 11:34:00 · 1105 阅读 · 0 评论 -
在一段字符串中另一字符串出现的指定的位置插入文字
string OldFrom=this.neirong.Text.Trim(); //.Replace("/r/n",""); OldFrom=""+OldFrom.Replace("/r/n",""); OldFrom=Regex.Replace(OldFrom,@"[/s]*","",RegexOptions.IgnoreCase); OldFrom=Regex.Rep原创 2006-08-30 15:46:00 · 1069 阅读 · 0 评论 -
c/s结构下生成报表及对报表传值
..using CrystalDecisions.Shared; using CrystalDecisions.ReportSource;using CrystalDecisions.CrystalReports.Engine;...事件处理: string exec="select * from userpwd"; this.sqlConnection1.Open();原创 2006-04-22 17:13:00 · 806 阅读 · 0 评论 -
c#下常用函数
1、DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=curre转载 2006-04-23 11:44:00 · 1551 阅读 · 0 评论 -
c#下asp.net调用webservice实现分页
在webservice服务器程序:[WebMethod] public int countuserpwd(string exec) { this.sqlConnection1.Open(); this.sqlDataAdapter1.SelectCommand.CommandText=exec; DataSet ds1=new DataSet(); this.sqlData原创 2006-04-20 22:23:00 · 4894 阅读 · 0 评论 -
c#下调用webservice在客户端利用datagrid本身功能分页
服务器端:public DataSet selectuserpwd(string exec) { this.sqlConnection1.Open(); this.sqlDataAdapter1.SelectCommand.CommandText=exec; DataSet ds1=new DataSet(); this.sqlDataAdapter1.Fill(ds1,"u原创 2006-04-21 12:46:00 · 1482 阅读 · 0 评论 -
解决问题:当前命令发生了严重错误。应放弃任何可能产生的结果
最近程序突然死循环,一查问题.发现出现了如题错误.最后找出的结果是在调用存储过程中未指明详细的数据类型.(据google结果说打了sp4才出现的,这就不知道了)对程序修改:SqlParameter paraNewsDetail=new SqlParameter("@Newsdetail",System.Data.SqlDbType.NText,1073741823); paraNew原创 2006-09-04 12:45:00 · 7051 阅读 · 0 评论 -
ASP.NET中实现身份验证方案
一、.NET中实现身份验证的可行性 Internet Information Services(IIS) 和 ASP .NET 均提供了安全模型,以便您对用户进行适当的身份验证。 ASP.NET 与 IIS 一起使用以支持身份验证,并使用基本、简要和Windows 身份验证。ASP.NET 支持 Microsoft Passport 身份验证服务,该服务提供单一登录服务和对用户配置文转载 2006-04-26 10:24:00 · 2989 阅读 · 0 评论 -
vs2005下根据websitemap读取生成导航条
websitemap: 源文件: position: absolute; top: 0px">原创 2006-05-11 22:49:00 · 1173 阅读 · 0 评论 -
61条面向对象设计的经验原则
(1)所有数据都应该隐藏在所在的类的内部。(2)类的使用者必须依赖类的共有接口,但类不能依赖它的使用者。(3)尽量减少类的协议中的消息。(4)实现所有类都理解的最基本公有接口[例如,拷贝操作(深拷贝和浅拷贝)、相等性判断、正确输出内容、从ASCII描述解析等等]。(5)不要把实现细节(例如放置共用代码的私有函数)放到类的公有接口中。如果类的两个方法有一段公共代码,那么就可以创建一个转载 2006-10-11 16:55:00 · 899 阅读 · 0 评论 -
读取生成的xml
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/1999/xhtml" > 无标题页 >原创 2006-10-11 16:57:00 · 912 阅读 · 0 评论 -
c#.net下的加密例子
引用:using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Text;using System.IO;using System.Security.Cryptography;using System.Web.UI;using原创 2006-05-25 21:48:00 · 979 阅读 · 0 评论 -
带参数多线程调用
main: Wthorse wt=new Wthorse(0,""); wt.SetName((Wthorse)wtArrayList[taskI]); this.statusBar1.Text="正在处理任务:"+TaskI; Thread jobThread=new Thread(new ThreadStart(wt.pri原创 2006-10-12 17:30:00 · 984 阅读 · 0 评论 -
多线程中子线程控制进度条(参阅msdn的)
private void button1_Click(object sender, System.EventArgs e) { flag=false; Thread thread=new Thread(new ThreadStart(target)); thread.IsBackground=true; thread.Start(); } public void target原创 2006-06-19 11:21:00 · 1193 阅读 · 0 评论 -
解决.net读excel字段为空的情况
当excel字段有内容而读不出来时候,尝试:string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties=Excel 8.0;HDR=Yes;IMEX=1;"; imex的意思: 0 is Export mode原创 2009-04-22 20:23:00 · 670 阅读 · 0 评论