public DateTime GetServerDateTime() { string str = "select getdate() as serverDate"; DatabaseCmd datacmd = new DatabaseCmd(); SqlDataReader myreader; try { datacmd.SqlExecuteReader(str, out myreader); if (myreader.Read()) { return myreader.GetDateTime(0); } else { return DateTime.Now; } } catch (Exception ex) { return DateTime.Now; //MessageBox.Show(ex.Message); } finally { datacmd.SqlReaderClose(); } }
} //从数据库中把二进制流读出写入还原成文件 public DateTime GetServerDateTime() { string str = "select getdate() as serverDate"; DatabaseCmd datacmd = new DatabaseCmd(); SqlDataReader myreader; try { datacmd.SqlExecuteReader(str, out myreader); if (myreader.Read()) { return(myreader.GetDateTime(0)); } else { return(DateTime.Now); } } catch (Exception ex) { return(DateTime.Now); //MessageBox.Show(ex.Message); } finally { datacmd.SqlReaderClose(); } }
public bool GetBinaryFromDatabase(string ID, string Ext, int Version, bool isModel, string outPath) { Byte[] ByteFile = null; string sqlstr = "select Data from [VehicleGeoInfo] where 汽车ID ='" + ID + "' and Ext ='" + Ext + "' and 版本=" + Version + " and 是否模板 ='" + isModel + "'"; DatabaseCmd databasecmd = new DatabaseCmd(); SqlDataReader myreader; databasecmd.SqlExecuteReader(sqlstr, out myreader); if(myreader.Read()) { ByteFile = (byte[])myreader[0]; BinaryToFile(ByteFile, outPath); } return true; }
public bool GetBinaryFromDatabase(string ID, string Ext, int Version, bool isModel, string outPath) { Byte[] ByteFile = null; string sqlstr = "select Data from [VehicleGeoInfo] where 汽车ID ='" + ID + "' and Ext ='" + Ext + "' and 版本=" + Version + " and 是否模板 ='" + isModel + "'"; DatabaseCmd databasecmd = new DatabaseCmd(); SqlDataReader myreader; databasecmd.SqlExecuteReader(sqlstr, out myreader); if (myreader.Read()) { ByteFile = (byte[])myreader[0]; BinaryToFile(ByteFile, outPath); } return(true); }