public static DataTable GetCustomTable(DataTable dataTable, string tempTableName, int userId) { DataTable rDataTable = new DataTable(tempTableName); CommonConnection connection = new CommonConnection(); try { if (tempTableName.Trim() != string.Empty) { //string strDelete = string.Format("Delete {0} Where UserId={1}", tempTableName, userId); string strDelete = string.Format("Delete {0} ", tempTableName, userId); connection.ExecuteNonQuery(strDelete); } String sql = "Select top (0) * from " + tempTableName; var tableStructure = connection.GetDataTable(sql); foreach (DataRow rowWithValue in dataTable.Rows) { tableStructure.Rows.Add(CustomDataRow(tableStructure, rowWithValue, userId)); } rDataTable = tableStructure; } catch (Exception) { throw; } finally { connection.Close(); } return rDataTable; }
public static DataTable GetBulkDataTable(DataTable dataTable, string tempTableName, string refName, int refValue) { DataTable rDataTable = new DataTable(tempTableName); CommonConnection connection = new CommonConnection(); try { String sql = "Select top (0) * from " + tempTableName; var tableStructure = connection.GetDataTable(sql); foreach (DataRow rowWithValue in dataTable.Rows) { tableStructure.Rows.Add(CustomDataRow(tableStructure, rowWithValue, refName, refValue)); } rDataTable = tableStructure; } catch (Exception) { throw; } finally { connection.Close(); } return rDataTable; }
public static DataTable GetBulkDataTable(DataTable dataTable, string tempTableName, string refName, int refValue) { DataTable rDataTable = new DataTable(tempTableName); CommonConnection connection = new CommonConnection(); try { String sql = "Select top (0) * from " + tempTableName; var tableStructure = connection.GetDataTable(sql); foreach (DataRow rowWithValue in dataTable.Rows) { tableStructure.Rows.Add(CustomDataRow(tableStructure, rowWithValue, refName, refValue)); } rDataTable = tableStructure; } catch (Exception) { throw; } finally { connection.Close(); } return(rDataTable); }
public static DataTable GetCustomTable(DataTable dataTable, string tempTableName, int userId) { DataTable rDataTable = new DataTable(tempTableName); CommonConnection connection = new CommonConnection(); try { if (tempTableName.Trim() != string.Empty) { string strDelete = ""; if (userId > 0) { strDelete = string.Format("Delete {0} Where UserId={1}", tempTableName, userId); } else if (userId == 0) { strDelete = ""; } else if (userId == -1) { strDelete = string.Format("Delete {0} ", tempTableName); } if (strDelete != "") { connection.ExecuteNonQuery(strDelete); } } String sql = "Select top (0) * from " + tempTableName; var tableStructure = connection.GetDataTable(sql); foreach (DataRow rowWithValue in dataTable.Rows) { tableStructure.Rows.Add(CustomDataRow(tableStructure, rowWithValue, userId)); } rDataTable = tableStructure; } catch (Exception) { throw; } finally { connection.Close(); } return(rDataTable); }