Code
posted @ 2009-02-03 16:47 陈旭85 阅读(1441) 评论(3) 编辑

描述:根据表t1.t2的ID关联,将表2的字段2更新到表1的字段1上

语法:   update t1 set 字段1=t2.字段2 from t2 where t1.ID=t2.ID

posted @ 2008-11-24 11:38 陈旭85 阅读(831) 评论(0) 编辑
sqlcmd -s 127.0.0.1 -i g:1.sql -U sa -P 123456
posted @ 2008-08-20 10:49 陈旭85 阅读(297) 评论(0) 编辑
摘要: [代码][代码]阅读全文
posted @ 2008-08-09 09:06 陈旭85 阅读(79) 评论(0) 编辑

 

Code
posted @ 2008-08-09 08:59 陈旭85 阅读(33) 评论(0) 编辑
Code
posted @ 2008-08-09 08:56 陈旭85 阅读(2178) 评论(1) 编辑

net use \\192.168.1.2 ""  /user:"Administrator"

 

 

 private  string CmdPing(string strIp)
        {

            Process p = new Process();

            p.StartInfo.FileName = "cmd.exe";

            p.StartInfo.UseShellExecute = false;

            p.StartInfo.RedirectStandardInput = true;

            p.StartInfo.RedirectStandardOutput = true;

            p.StartInfo.RedirectStandardError = true;

            p.StartInfo.CreateNoWindow = true;

            string pingrst;

            p.Start();

            p.StandardInput.WriteLine("ping -n 1 " + strIp);

            p.StandardInput.WriteLine("exit");

            string strRst = p.StandardOutput.ReadToEnd();

            if (strRst.IndexOf("(0% loss)") != -1)

                pingrst = "连接";

            else if (strRst.IndexOf("Destination host unreachable.") != -1)

                pingrst = "无法到达目的主机";

            else if (strRst.IndexOf("Request timed out.") != -1)

                pingrst = "超时";

            else if (strRst.IndexOf("Unknown host") != -1)

                pingrst = "无法解析主机";

            else

                pingrst = strRst;

            p.Close();

            return pingrst;

        }

 

 

tcp 发送

public static bool NetworkCommand(string CommandText, string Ip, string Port)
        {
            try
            {
                byte[] bt = System.Text.Encoding.Default.GetBytes(CommandText);

                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(Ip), Convert.ToInt32(Port));
                TcpClient tc = new TcpClient();
                tc.Connect(ep);

                NetworkStream nstream = tc.GetStream();
                nstream.Write(bt, 0, bt.Length);
                tc.Close();

                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return false;
        }

 

 

tcp监听

private void SocketLis()
        {
            Int32 port = Config.SocketPort;
            IPAddress localAddr = IPAddress.Any;//(/*"117.25.162.138"/*"127.0.0.1"*/);
           // IPAddress localAddr = IPAddress.Parse("127.0.0.1");
            tcl = new TcpListener(localAddr, port);
            tcl.Start();
            DrawListView("在" + port.ToString() + "端口启动监听");
            while (true)
            {
               
                TcpClient tc = tcl.AcceptTcpClient();
                DrawListView("收到网络上的信息");
                NetworkStream netstream = tc.GetStream();
                byte[] bt = new byte[256];
                int i;
                string revdate="";
                DateTime dt;
                while ((i = netstream.Read(bt, 0, bt.Length)) != 0)
                {
                    revdate = System.Text.Encoding.Default.GetString(bt, 0, i);
                }
                DrawListView(revdate);
                try
                {
                    dt = DateTime.Parse(revdate);
                    TimeSpan ts = dt - DateTime.Now;
                    if (ts.Ticks > 0)
                    {
                        tr.Change(ts, new TimeSpan(-1));  
                    }
                }
                catch(Exception ex)
                {
                    DrawListView("Socket接收出错:"+ex.Message);
                }
            }
        }

posted @ 2008-07-25 09:45 陈旭85 阅读(63) 评论(0) 编辑
摘要: [代码]阅读全文
posted @ 2008-07-21 10:42 陈旭85 阅读(458) 评论(0) 编辑
摘要: 当设计表的时候没有建组合字段唯一约束,以后需要增加这一约束时,却发现表里已经有了很多重复记录了。 请看看我用的去掉表里组合字段重复的记录方法: 假设原始表名为source_table,字段名1为field_name1,字段名2为field_name2。 (当然稍加修改也可以用到三个及以上组合字段重复的情况) 第一步: 生成组合字段重复的临时表source_dup_simple create tab...阅读全文
posted @ 2008-06-11 17:09 陈旭85 阅读(438) 评论(0) 编辑
摘要: privatevoidbtn_send_Click(objectsender,EventArgse){byte[]bt=System.Text.Encoding.Default.GetBytes(this.txt_msg.Text);TcpClienttc=newTcpClient(this.txt_tarip.Text,int.Parse(this.txt_tarport.Text));Netw...阅读全文
posted @ 2008-05-13 15:09 陈旭85 阅读(305) 评论(0) 编辑