在同一局域网内,有一台专门存放数据库 的服务器,
现在我要从本机获取服务器时间,请问,怎么样才能实现,,,

解决方案 »

  1.   

    System.Diagnostics.Process p=new System.Diagnostics.Process();
    p.StartInfo.UseShellExecute=false;
    p.StartInfo.CreateNoWindow=true;
    p.StartInfo.RedirectStandardInput=true;
    p.StartInfo.RedirectStandardOutput=true;
    p.StartInfo.FileName="cmd";
    p.Start();
    p.StandardInput.WriteLine(@"net time \\user");
    p.StandardInput.WriteLine("exit");
    string s=p.StandardOutput.ReadToEnd();
    p.WaitForExit();
    MessageBox.Show(s);此段代码,在有权限的情况下可以取得网络中其它机器的时间,
    不过在无访问权限的情况下就不会有了,
    抛砖引玉,楼主再想想方法。
      

  2.   

    用Remoting
    http://community.csdn.net/Expert/topic/4272/4272644.xml?temp=9.531802E-02
    在组件端加个线程
    时间间隔你自己定
      

  3.   

    执行SQL命令  SELECT GETDATE() .
    至于怎么使用SqlConnection,SqlCommand有很多介绍的文章
      

  4.   

    多谢四位大虾的帮助,,,我的问题已经解决,,,,用的是   pupo(泡泡)   的方法,,,,谢谢你们,,,,
      

  5.   

    用Webservice吧,这个比较方便一点
    新建一个Webservice, 添加如下方法即可
    [WebMethod]
    public string GetCurrentServerTime()
    {
       return DateTime.ToString();
    }客户端去取这个方法返回的字符串就可以了