public Dictionary <string, string> GetOptionsFields(Guid id, string sql) { Dictionary <string, string> list = new Dictionary <string, string>(); RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection(); RoadFlow.Data.Model.DBConnection dbconn = bdbconn.Get(id); using (System.Data.IDbConnection conn = bdbconn.GetConnection(dbconn)) { if (conn == null) { return(list); } try { conn.Open(); } catch (Exception ex) { System.Web.HttpContext.Current.Response.Write("连接数据库出错:" + ex.Message); RoadFlow.Platform.Log.Add(ex); } List <System.Data.IDataParameter> parList = new List <System.Data.IDataParameter>(); System.Data.IDbDataAdapter dataAdapter = bdbconn.GetDataAdapter(conn, dbconn.Type, sql, parList.ToArray()); System.Data.DataSet ds = new System.Data.DataSet(); dataAdapter.Fill(ds); foreach (System.Data.DataRow row in ds.Tables[0].Rows) { list.Add(row[0].ToString(), row[1].ToString()); } return(list); } }
public void ExtractTableParameters(string TableName, System.Data.IDbDataAdapter adapter, out DatabaseCache InsertCache, out DatabaseCache DeleteCache, out DatabaseCache UpdateCache, out DatabaseCache IsExistCache, out System.Data.DataTable dt) { adapter.SelectCommand.CommandText = "select top 1 * from " + TableName; DataSet ds = new DataSet(); dt = adapter.FillSchema(ds, SchemaType.Source)[0]; dt.TableName = TableName; OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter as OleDbDataAdapter); builder.ConflictOption = ConflictOption.OverwriteChanges; //builder.SetAllValues = false; OleDbCommand InsertCmd = builder.GetInsertCommand(true); builder.ConflictOption = ConflictOption.OverwriteChanges; InsertCache = new DatabaseCache(InsertCmd.CommandText, InsertCmd.Parameters); InsertCache.CurrentTable = dt; foreach (DataColumn c in dt.Columns) { if (c.AutoIncrement) { InsertCache.IsHaveAutoIncrement = true; InsertCache.SQL += ";Select @@IDENTITY;"; break; } } OleDbCommand UpdateCmd = builder.GetUpdateCommand(true); UpdateCache = new DatabaseCache(UpdateCmd.CommandText, UpdateCmd.Parameters); UpdateCache.CurrentTable = dt; OleDbCommand DeleteCmd = builder.GetDeleteCommand(true); DeleteCache = new DatabaseCache(DeleteCmd.CommandText, DeleteCmd.Parameters); DeleteCache.CurrentTable = dt; IsExistCache = new DatabaseCache(DeleteCmd.CommandText, DeleteCmd.Parameters); IsExistCache.CurrentTable = dt; IsExistCache.SQL = IsExistCache.SQL.Replace("DELETE FROM [" + TableName + "]", "Select count(1) from [" + TableName + "] with(nolock) "); }
public System.Data.DataTable QueryForDataTable(string statementName, StrObjectDict paramObject, StrObjectDict dictParam, System.Collections.Generic.IDictionary <string, System.Data.ParameterDirection> dictParamDirection, out System.Collections.Hashtable htOutPutParameter) { ISqlMapper sqlMap = this.GetSqlMap(); System.Data.DataSet dataSet = new System.Data.DataSet(); bool flag = false; ISqlMapSession sqlMapSession = sqlMap.LocalSession; if (sqlMapSession == null) { sqlMapSession = new SqlMapSession(sqlMap); sqlMapSession.OpenConnection(); flag = true; } System.Data.IDbCommand dbCommand = this.GetDbCommand(sqlMap, statementName, paramObject, dictParam, dictParamDirection, System.Data.CommandType.StoredProcedure); try { dbCommand.Connection = sqlMapSession.Connection; System.Data.IDbDataAdapter dbDataAdapter = sqlMapSession.CreateDataAdapter(dbCommand); dbDataAdapter.Fill(dataSet); } finally { if (flag) { sqlMapSession.CloseConnection(); } } htOutPutParameter = new System.Collections.Hashtable(); foreach (System.Data.IDataParameter dataParameter in dbCommand.Parameters) { if (dataParameter.Direction == System.Data.ParameterDirection.Output) { htOutPutParameter[dataParameter.ParameterName] = dataParameter.Value; } } return(dataSet.Tables[0]); }
/// <summary> /// Fills The DataSet /// </summary> /// <param name="da">DataAdapter</param> /// <param name="dsDataSet">DataSet</param> /// <param name="sTable">Table Name</param> public static void FillDataSet(System.Data.IDbDataAdapter da, System.Data.DataSet dsDataSet, string sTable) { ((XrDbDataAdapter)da).Fill(dsDataSet, sTable); }
public System.Data.Common.DbCommandBuilder CreateAdapterCommand(ref System.Data.IDbDataAdapter DbDataAdapter) { throw new Exception("The method or operation is not implemented."); }