public DataSet ConnectCSV(string filetable, bool bFill) { DataSet ds = new DataSet(); try { // You can get connected to driver either by using DSN or connection string // Create a connection string as below, if you want to use DSN less connection. The DBQ attribute sets the path of directory which contains CSV files string strConnString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + txtCSVFolderPath.Text.Trim() + ";Extensions=asc,csv,tab,txt;Persist Security Info=False"; string sql_select; System.Data.Odbc.OdbcConnection conn; //Create connection to CSV file conn = new System.Data.Odbc.OdbcConnection(strConnString.Trim()); // For creating a connection using DSN, use following line //conn = new System.Data.Odbc.OdbcConnection(DSN="MyDSN"); //Open the connection conn.Open(); //Fetch records from CSV sql_select = "select * from [" + filetable + "]"; obj_oledb_da = new System.Data.Odbc.OdbcDataAdapter(sql_select, conn); //Fill dataset with the records from CSV file obj_oledb_da.Fill(ds, "Customers"); if (bFill) { //Set the datagrid properties dGridCSVdata.DataSource = ds; dGridCSVdata.DataMember = "Customers"; //Close Connection to CSV file } conn.Close(); } catch (Exception exe) //Error { MMSUtility.LogFile(exe.Message, "", "ConnectCSV", exe.LineNumber(), "PrintLetterDialog"); MessageBox.Show(exe.Message); } return ds; }
public static System.Data.DataSet ExecuteDatasetQueryOnDB(string sSQL, string sConnectionString) { System.Data.Odbc.OdbcDataAdapter QDataAdapter = null; DataSet QDataSet = null; try { QDataSet = new DataSet(); QDataAdapter = new System.Data.Odbc.OdbcDataAdapter(sSQL, sConnectionString); QDataAdapter.Fill(QDataSet); return QDataSet; } finally { if (QDataSet != null) QDataSet.Dispose(); QDataSet = null; if (QDataAdapter != null) QDataAdapter.Dispose(); QDataAdapter = null; } }
private void btLoad_Click(object sender, System.EventArgs e) { try { System.Data.DataSet dataset = new System.Data.DataSet(); using (System.Data.Odbc.OdbcDataAdapter adapter = new System.Data.Odbc.OdbcDataAdapter(txtSqlQuery.Text, txtConnectionString.Text)) { adapter.Fill(dataset); } //Debug Trace dataset.Tables[0].RowDeleted += new System.Data.DataRowChangeEventHandler(frmSample9_RowDeleted); dataset.Tables[0].RowChanged += new System.Data.DataRowChangeEventHandler(frmSample9_RowChanged); dataset.Tables[0].ColumnChanged += new System.Data.DataColumnChangeEventHandler(frmSample9_ColumnChanged); lbRowsNumber.Text = "Rows: " + dataset.Tables[0].Rows.Count; dataGrid.FixedColumns = 1; dataGrid.FixedRows = 1; dataGrid.Columns.Clear(); DevAge.ComponentModel.BoundDataView bd = new DevAge.ComponentModel.BoundDataView(dataset.Tables[0].DefaultView); bd.AllowNew = chkAllowNew.Checked; bd.AllowEdit = chkEdit.Checked; bd.AllowDelete = chkAllowDelete.Checked; dataGrid.DataSource = bd; dataGrid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; dataGrid.Columns[0].Width = 20; dataGrid.Columns.AutoSizeView(); } catch(Exception err) { DevAge.Windows.Forms.ErrorDialog.Show(this, err, "Error loading dataset"); } }
private void start_base_import(String table, String table_name, String code) { SqlConnection sql_conn; SqlCommand sql_cmd; SqlDataAdapter da; DataTable dt = new DataTable(); /*Connect to Sql server*/ string strConnection = "user id=sa;password=wang419420;"; strConnection += "initial catalog=" + dbname + ";Server=192.168.3.101\\foodsd;"; strConnection += "Connect Timeout=30"; sql_conn = new SqlConnection(strConnection); sql_cmd = new SqlCommand("select * from [banzhaoyun].[dbo].[" + table_name + "]"); sql_cmd.Connection = sql_conn; da = new System.Data.SqlClient.SqlDataAdapter(sql_cmd); da.Fill(dt); da.FillSchema(dt, System.Data.SchemaType.Mapped); /*Read DBF file content*/ try { //MessageBox.Show(table + " " + table_name + " " + code); System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(); //String table = "E:\\banzhaoyun\\base\\" + table_name + ".DBF"; string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"; conn.ConnectionString = connStr; conn.Open(); String sql = @"select * from " + table; System.Data.Odbc.OdbcDataAdapter dbf_da = new System.Data.Odbc.OdbcDataAdapter(sql, conn); DataTable dbf_dt = new DataTable(); dbf_dt.Clear(); dbf_da.Fill(dbf_dt); conn.Close(); for (int j = 0; j < dbf_dt.Rows.Count; j++) { DataRow newrow = dt.NewRow(); newrow[0] = code; for (int k = 0; k < dbf_dt.Columns.Count; k++) newrow[k + 1] = dbf_dt.Rows[j][k]; dt.Rows.Add(newrow); } System.Console.WriteLine(table); sql_cmd.Connection.Open(); SqlCommandBuilder cb = new SqlCommandBuilder(da); da.Update(dt); sql_cmd.Connection.Close(); } catch (Exception ex) { MessageBox.Show(table + " " + table_name); } }
private void start_daily_import_252(String table_name, String code) { SqlConnection sql_conn; SqlCommand sql_cmd; SqlDataAdapter da; DataTable dt = new DataTable(); /*Connect to Sql server*/ string strConnection = "user id=sa;password=wang419420;"; strConnection += "initial catalog=fsrDataOrig;Server=192.168.3.252;"; strConnection += "Connect Timeout=30"; sql_conn = new SqlConnection(strConnection); sql_cmd = new SqlCommand("select * from dbo." + table_name); sql_cmd.Connection = sql_conn; da = new System.Data.SqlClient.SqlDataAdapter(sql_cmd); //da.Fill(dt); da.FillSchema(dt, System.Data.SchemaType.Mapped); /*Read DBF file content*/ foreach (String path in folders) { if (path.Contains("old")) continue; System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(); try { String p = path.Replace(" ", ""); String table = p + "\\" + table_name + ".DBF"; string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"; conn.ConnectionString = connStr; if (!File.Exists(table)) { MessageBox.Show(table + " is not exist"); continue; } conn.Open(); String sql; if (table.Contains("A_TRAN")) sql = @"select ref_num, outlet, tran_type, in_date from " + table; else sql = @"select * from " + table; System.Data.Odbc.OdbcDataAdapter dbf_da = new System.Data.Odbc.OdbcDataAdapter(sql, conn); DataTable dbf_dt = new DataTable(); dbf_dt.Clear(); dbf_da.Fill(dbf_dt); conn.Close(); int year = path.IndexOf('2'); DateTime date = Convert.ToDateTime(path.Substring(year, 10).Replace('\\', '-')); int k = 0; //System.Console.WriteLine(table); for (int j = 0; j < dbf_dt.Rows.Count; j++) { if (table.Contains("A_PAY")) { DataRow newrow = dt.NewRow(); for (k = 0; k < dbf_dt.Columns.Count; k++) { newrow[k] = dbf_dt.Rows[j][k]; } newrow[k] = date; dt.Rows.Add(newrow); } else if (table.Contains("A_TRAN")) { DataRow newrow = dt.NewRow(); newrow[0] = dbf_dt.Rows[j][0]; newrow[3] = dbf_dt.Rows[j][1]; newrow[5] = dbf_dt.Rows[j][2]; newrow[11] = dbf_dt.Rows[j][3]; dt.Rows.Add(newrow); } else { DataRow newrow = dt.NewRow(); newrow[0] = code; for (k = 0; k < dbf_dt.Columns.Count; k++) { newrow[k + 1] = dbf_dt.Rows[j][k]; } if (table.Contains("T_ATT") || table.Contains("T_PAY")) newrow[k + 1] = date; dt.Rows.Add(newrow); } } sql_cmd.Connection.Open(); SqlCommandBuilder cb = new SqlCommandBuilder(da); da.Update(dt); sql_cmd.Connection.Close(); dt.Clear(); logList.Items.Insert(0, table); } catch (Exception ex) { MessageBox.Show(ex.ToString()); logList.Items.Insert(0, ex.ToString()); conn.Close(); sql_cmd.Connection.Close(); dt.Clear(); } } }
private void check_daily_dbf_date(String table_name, String code) { foreach (String path in folders) { if (path.Contains("old")) continue; System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(); try { String p = path.Replace(" ", ""); String table = p + "\\" + table_name + ".DBF"; string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"; conn.ConnectionString = connStr; if (!File.Exists(table)) { MessageBox.Show(table + " is not exist"); continue; } conn.Open(); String sql = @"select * from " + table; System.Data.Odbc.OdbcDataAdapter dbf_da = new System.Data.Odbc.OdbcDataAdapter(sql, conn); DataTable dbf_dt = new DataTable(); dbf_dt.Clear(); dbf_da.Fill(dbf_dt); conn.Close(); foreach (DataRow row in dbf_dt.Rows) { DateTime in_date = Convert.ToDateTime(row[11]); DateTime bill_date = Convert.ToDateTime(row[13]); if (in_date.ToString("yyyy-MM-dd") != dateText.Text || bill_date.ToString("yyyy-MM-dd") != dateText.Text) logList.Items.Add(table + ": REF_NUM: " + row[0] + " IN_DATE: " + in_date.ToString("yyyy-MM-dd") + " BILL_DATE: " + bill_date.ToString("yyyy-MM-dd")); } } catch (Exception ex) { } } }
public IActionResult OnPostExecuteQuery(string query, string connections) { CloudQuery.Models.QueryResult qr = new Models.QueryResult(); qr.Message = "Query execution incomplete"; bool isMSI = "true".CompareTo(System.Environment.GetEnvironmentVariable("MSI")) == 0; bool isAE = "true".CompareTo(System.Environment.GetEnvironmentVariable("ODBC_ALWAYSENCRYPTED")) == 0; // get the connectionObject var conn = Newtonsoft.Json.JsonConvert.DeserializeObject <CloudQuery.Models.DBConnection>(connections); if (conn.DBName.StartsWith("#")) { PopulateConnectionDataFromMount(conn); } string connectionString = string.Format("Server=tcp:{0};Database={1};Uid={2}@{0};Pwd={3};Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30;", conn.DBServer, conn.DBName, conn.Username, conn.Password); if (isMSI) { connectionString = string.Format("Server=tcp:{0};Database={1};Uid={2}@{0};Authentication=ActiveDirectoryMsi;Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30", conn.DBServer, conn.DBName, conn.Username); } if (isMSI && isAE) { connectionString = string.Format("Server=tcp:{0};Database={1};Uid={2};Authentication=ActiveDirectoryMsi;Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30;ColumnEncryption=Enabled;KeyStoreAuthentication=KeyVaultManagedIdentity;KeyStorePrincipalId={2}", conn.DBServer, conn.DBName, conn.Username); } connectionString = "Driver={ODBC Driver 17 for SQL Server};" + connectionString; Console.WriteLine($"ConnectionString: {connectionString}"); try { int rowsReturned = 0; System.Data.DataSet ds; using (System.Data.Odbc.OdbcDataAdapter adapter = new System.Data.Odbc.OdbcDataAdapter(query, connectionString)) { ds = new System.Data.DataSet(); rowsReturned = adapter.Fill(ds); } // only selects will return a Table of results; if (ds.Tables.Count == 0) // not a table { qr.Message = "Query completed successfully"; } else if (ds.Tables.Count == 1) { // return the results qr.Results = ds.Tables[0]; // return rowsAffected for message qr.Message = string.Format("{0} rows returned.", rowsReturned); } } catch (Exception ex) { qr.Exception = ex; qr.Message = ex.Message; } ViewData["results"] = qr; return(View("Index")); }
/// <summary> /// 将dataTable转换成DBF文件 /// </summary> /// <param name="dt">需要导出数据的DataTable</param> /// <param name="strExportPath">导出路径</param> /// <param name="strExportFile">导出文件名,要带有.dbf的后缀</param> /// <param name="strStructFile">标准库的文件名,含有路径</param> public bool CreateDBF(DataTable dt, string strExportPath, string strExportFile, string strStructFile, bool bol) { //第一步:拷贝标准库 CreaterFolder(strExportPath); System.IO.File.Copy(strStructFile, strExportPath + @"\" + strExportFile, true); //建立连接,读取拷贝过去的那个库,注意连接字符串,使用的是vfp9.0的driver System.Data.Odbc.OdbcConnection conn1 = new System.Data.Odbc.OdbcConnection(); //conn1.ConnectionString = @"Provider=VFPOLEDB.1;DATA Source=" + strExportPath + @"\" + strExportFile + ";"; //conn1.ConnectionString = @"Provider=vfpoledb;DATA Source=" + strExportPath + @"\" + ";Collating Sequence=machine;"; conn1.ConnectionString = @"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + strExportPath + @"\" + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"; //conn1.ConnectionString = @"Provider=vfpoledb;Data Source=C:\Users\deng\Desktop\HQMS\HQMS2013\数据文件模板\数据文件模板\DBF文件模板(20121214)\完整的DBF模板\;Collating Sequence=machine;"; string strSQL = "SELECT * FROM " + strExportFile.Replace(".dbf", ""); System.Data.Odbc.OdbcDataAdapter adp = new System.Data.Odbc.OdbcDataAdapter(strSQL, conn1); System.Data.DataSet ds = new DataSet(); conn1.Open(); adp.Fill(ds, "DBF"); DataTable dtDBF = ds.Tables["DBF"]; string sqlInsert = ""; if (bol) { sqlInsert = @"insert into " + strExportFile.Replace(".dbf", "") + @"(p900, p6891, p686, p800, p1, p2, p3, p4, p5, p6, p7, p8, p9, p101, p102, p103, p11, p12, p13, p801, p802, p803, p14, p15, p16, p17, p171, p18, p19, p20, p804, p21, p22, p23, p231, p24, p25, p26, p261, p27, p28, p281, p29, p30, p301, p31, p321, p322, p805, p323, p324, p325, p806, p326, p327, p328, p807, p329, p3291, p3292, p808, p3293, p3294, p3295, p809, p3296, p3297, p3298, p810, p3299, p3281, p3282, p811, p3283, p3284, p3285, p812, p3286, p3287, p3288, p813, p3289, p3271, p3272, p814, p3273, p3274, p3275, p815, p3276, p689, p351, p352, p816, p353, p354, p817, p355, p356, p818, p361, p362, p363, p364, p365, p366, p371, p372, p38, p39, p40, p411, p412, p413, p414, p415, p421, p422, p687, p688, p431, p432, p433, p434, p819, p435, p436, p437, p438, p44, p45, p46, p47, p490, p491, p820, p492, p493, p494, p495, p496, p497, p498, p4981, p499, p4910, p4911, p4912, p821, p4913, p4914, p4915, p4916, p4917, p4918, p4919, p4982, p4920, p4921, p4922, p4923, p822, p4924, p4925, p4526, p4527, p4528, p4529, p4530, p4983, p4531, p4532, p4533, p4534, p823, p4535, p4536, p4537, p4538, p4539, p4540, p4541, p4984, p4542, p4543, p4544, p4545, p824, p4546, p4547, p4548, p4549, p4550, p4551, p4552, p4985, p4553, p4554, p45002, p45003, p825, p45004, p45005, p45006, p45007, p45008, p45009, p45010, p45011, p45012, p45013, p45014, p45015, p826, p45016, p45017, p45018, p45019, p45020, p45021, p45022, p45023, p45024, p45025, p45026, p45027, p827, p45028, p45029, p45030, p45031, p45032, p45033, p45034, p45035, p45036, p45037, p45038, p45039, p828, p45040, p45041, p45042, p45043, p45044, p45045, p45046, p45047, p45048, p45049, p45050, p45051, p829, p45052) values ( ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; } else { sqlInsert = @"insert into " + strExportFile.Replace(".dbf", "") + @"( p3,p22, p45053, p45054, p45055, p45056, p45057, p45058, p45059, p45060, p45061, p561, p562, p563, p564, p6911, p6912, p6913, p6914, p6915, p6916, p6917, p6918, p6919, p6920, p6921, p6922, p6923, p6924, p6925, p57, p58, p581, p60, p611, p612, p613, p59, p62, p63, p64, p651, p652, p653, p654, p655, p656, p66, p681, p682, p683, p684, p685, p67, p731, p732, p733, p734, p72, p830, p831, p741, p742, p743, p782, p751, p752, p754, p755, p756, p757, p758, p759, p760, p761, p762, p763, p764, p765, p767, p768, p769, p770, p771, p772, p773, p774, p775, p776, p777, p778, p779, p780, p781) values (?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; } for (int i = 0; i < dt.Rows.Count; i++) { List <object> sqlparams = new List <object>(); for (int j = 0; j < dt.Columns.Count; j++) { Type type = dt.Columns[j].DataType; Type typeDBF = dtDBF.Columns[j].DataType; if (dt.Rows[i][j].ToString().Length == 0) { double a = 1.56; object b = (object)a; sqlparams.Add(DBNull.Value); } else { if (type.Name != typeDBF.Name) { if (typeDBF == typeof(int)) { sqlparams.Add(int.Parse(dt.Rows[i][j].ToString())); } else if (typeDBF == typeof(decimal)) { sqlparams.Add(dt.Rows[i][j]); } else if (typeDBF == typeof(string)) { sqlparams.Add(dt.Rows[i][j].ToString()); } else if (typeDBF == typeof(DateTime)) { sqlparams.Add(DateTime.Parse(dt.Rows[i][j].ToString())); } } else { if (dt.Columns[j].ColumnName == "P66") { object o = dt.Rows[i][j]; string s = dt.Rows[i][j].ToString(); decimal d = (decimal)dt.Rows[i][j]; sqlparams.Add(int.Parse(dt.Rows[i][j].ToString())); } else { sqlparams.Add(dt.Rows[i][j]); } } } } bool bl = Execute(conn1, sqlInsert, sqlparams.ToArray()); if (!bl) { MessageBox.Show("生成PDF文件失败"); return(false); } } conn1.Close(); return(true); #region //string strSQL = "SELECT * FROM " + strExportFile.Replace(".dbf", ""); //System.Data.Odbc.OdbcDataAdapter adp = new System.Data.Odbc.OdbcDataAdapter(strSQL, conn1); ////初始化一个CommandBuilder,目的是使得adp的更新操作初始化 //System.Data.Odbc.OdbcCommandBuilder cmdBld = new System.Data.Odbc.OdbcCommandBuilder(adp); ////adp.InsertCommand = cmdBld.GetInsertCommand(); ////adp.DeleteCommand = cmdBld.GetDeleteCommand(); ////adp.UpdateCommand = cmdBld.GetUpdateCommand(); //System.Data.DataSet ds = new DataSet(); //conn1.Open(); //adp.Fill(ds, "DBF"); //conn1.Close(); //DataTable dt1 = ds.Tables["DBF"]; //dt1.PrimaryKey = new DataColumn[] { dt1.Columns["P3"], dt1.Columns["P2"] };//建立一个主键 ////循环读取dt的数据添加到dt1,注意方法,还有一个就是null值的处理,具体要根据你的dbf库结构来设定。 //for (int i = 0; i < dt.Rows.Count; i++) //{ // DataRow dr = dt1.NewRow(); // for (int j = 0; j < dt.Columns.Count; j++) // { // //如果是null,则赋值为DBNull.Value;如果不是null,则插入原始值dt.Rows[i][dt1.Colums[j].ColumnName.ToString()] // dr[j] = dt.Rows[i][dt1.Columns[j].ColumnName.ToString()] == null ? DBNull.Value : dt.Rows[i][dt1.Columns[j].ColumnName.ToString()]; // } // dt1.Rows.Add(dr); //} ////更新dt1,系统自动将数据添加到dbf库中 //adp.Update(ds, "DBF"); #endregion }
// UPLOAD BUTTON HANDLER ------------------------------------------------------------------------------------------------------- protected void uploadbutton_Click(object sender, EventArgs e) { // Get button ID Button getbuttonID = (Button)sender; string id = getbuttonID.ID.Replace("_button",""); // Use button ID to find similarly named upload control ID FileUpload uploadcontrol = (FileUpload)Form.FindControl(id); // Only upload if control has file selected if (uploadcontrol.HasFile) { // Add upload path String savePath = @"c:\temp\"; // Retrieve filename from upload control String fileName = uploadcontrol.FileName; // Save data to web server uploadcontrol.SaveAs(savePath + fileName); // Fill GridView // Establish text driver connection System.Data.Odbc.OdbcConnection csv_connection; System.Data.Odbc.OdbcDataAdapter csv_adapter; // Create temporary data table to store CSV data DataTable csv_data = new DataTable(); // Create connection string and execute connection to CSV string csv_connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + savePath + ";"; csv_connection = new System.Data.Odbc.OdbcConnection(csv_connectionString); // Fill adapter with SELECT * query from CSV csv_adapter = new System.Data.Odbc.OdbcDataAdapter("select * from [" + fileName + "]", csv_connection); csv_adapter.Fill(csv_data); // Close CSV connection csv_connection.Close(); // Find GridView and fill GridView filedata = (GridView)Form.FindControl(id + "_table"); filedata.DataSource = csv_data; filedata.DataBind(); // SESSION MODIFICATION // DataSet session_datanew = new DataSet(); session_datanew.Tables.Add(csv_data); session_datanew.DataSetName = "PCADATA"; Registry.Registry registry = Registry.Registry.getRegistry(Session); registry.registerDataset(session_datanew); Analysis.ParameterStream stream = Analysis.ParameterStream.getStream(Session); stream.set("dataSetName", "PCADATA"); //----------------------// } }