public static DateTime GetSystemDateTime() { SqlServerExecute sqlServerExe = new SqlServerExecute(); //string sSQL = "select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual"; // Oracle数据库,备用 string sql = "select Convert(varchar(20),getdate(),120)"; // SqlServer 形式如: 2013-05-22 20:26:34 object obj = sqlServerExe.ExecuteScalar(sql); return(Convert.ToDateTime(obj)); }
private void BindArea() { string sql = "select 0 as Id,'-所有桌台-' AS Name union Select id,name From areas Where id In (Select area_id From salespointarea Where SalesPoint_Id = " + CurrentSystemInfo.SalesPoint.Id.ToString() + ")"; System.Data.DataTable dt = new SqlServerExecute().FillDataTable(System.Data.CommandType.Text, sql); if (dt.DefaultView.Count > 0) { this.maxPageCount = Convert.ToInt32(dt.DefaultView.Count / 9) + 1; } if (this.maxPageCount <= 0) { this.maxPageCount = 1; } if (this.currentPage < 1) { this.currentPage = 1; } if (this.currentPage > this.maxPageCount) { this.currentPage = this.maxPageCount; } int i = 0; System.Drawing.Font f = new Font("宋体", 10); for (i = 0; i < 9; i++) { this.btnArea[i].Text = ""; this.btnArea[i].Tag = ""; this.btnArea[i].Font = f; if (((this.currentPage - 1) * 9) + i + 1 <= dt.DefaultView.Count) { this.btnArea[i].Tag = Convert.ToInt32(dt.DefaultView[((this.currentPage - 1) * 9) + i]["Id"]); this.btnArea[i].Text = dt.DefaultView[((this.currentPage - 1) * 9) + i]["Name"].ToString(); } } for (i = 0; i < this.btnArea.Length; i++) { if (!this.btnArea[i].Tag.ToString().Equals("")) { if (this.currentAreaID == Convert.ToInt32(this.btnArea[i].Tag)) { this.btnArea[i].Font = new Font("宋体", 10, System.Drawing.FontStyle.Bold); } } } if (!this.btnArea[1].Tag.ToString().Equals("")) { this.currentAreaID = Convert.ToInt32(this.btnArea[1].Tag); } }
/// <summary> /// 测试数据库能否连接成功 /// </summary> /// <returns></returns> static bool TestDbConnect() { try { SqlServerExecute sqlExe = new SqlServerExecute(); System.Data.Common.DbConnection conn = SqlServerExecute.CreateConnection(); conn.Open(); return(true); } catch { return(false); } }
private void SqlServerTest() { string connStr = "server=localhost;uid=sa;pwd=12345678;database=PIMS_PSA"; string sql = "select * from tagconfig"; string delSql = "delete from tagconfig where tagId=1"; ISqlExecute exe = new SqlServerExecute(connStr); //var result1 = exe.QueryMany<TagConfig>(sql); //var result2 = exe.QuerySingle<TagConfig>(sql); //var result3 = exe.ExecuteScalar<int>(sql); var result4 = exe.SqlQueryTest(delSql); }
public List <DataTable> GetTablesInDatabase(List <string> tableNameList) { SqlServerExecute sqlServerExe = new SqlServerExecute(); //DataTable userTables = sqlServerExe.FillDataTable(CommandType.Text, "select name from sysobjects where type = 'U'"); List <DataTable> tableList = new List <DataTable>(); foreach (String tableName in tableNameList) { string sql = string.Format("select * from {0}", tableName); DataTable dt = sqlServerExe.FillDataTable(CommandType.Text, sql); dt.TableName = tableName; tableList.Add(dt); } return(tableList); }
public List <string> GetTableNamesInDatabase(string dataBaseName) { SqlServerExecute sqlServerExe = new SqlServerExecute(); DataTable userTables = sqlServerExe.FillDataTable(CommandType.Text, "use " + dataBaseName + "; select name from sysobjects where type = 'U'"); List <string> tableList = new List <string>(); foreach (DataRow row in userTables.Rows) { string sql = string.Format("select * from {0}", row["Name"].ToString()); if (row["name"] != DBNull.Value) { tableList.Add(Convert.ToString(row["Name"])); } } return(tableList); }
public System.Data.DataTable GetDishTableInfo(string sql) { SqlServerExecute SqlExe = new SqlServerExecute(); return(SqlExe.FillDataTable(CommandType.Text, sql)); }
public DataTable GetDatabases() { SqlServerExecute sqlServerExe = new SqlServerExecute(); return(sqlServerExe.FillDataTable(CommandType.Text, "select name from master..sysdatabases")); }
public string GetServerName() { SqlServerExecute sqlServerExe = new SqlServerExecute(); return(sqlServerExe.ExecuteScalarToStr("select @@Servername")); }
private DataTable GetDataTable() { SqlServerExecute exe = new SqlServerExecute(); return(exe.FillDataTable(CommandType.Text, "select Id, Name, Code,Memo from dishmenu")); }