可以用ADO.NET啊,比ODBC好用吧应该。如下:
SqlConnection con=new SqlConnection("database=master;data source=(local);user id=sa;password=sa");
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandText="select getdate()";
DateTime now=DateTime.Now;
try
{
con.Open();
now=(DateTime)cmd.ExecuteScalar();
con.Close();
}
catch
{}
MessageBox.Show(now.ToShortTimeString());