public object[] db_access(string strSQL) { ADODB.Connection objCon; ADODB.Recordset objRec; object[,] dataRows; object[] dataSuite; string strCon; objCon = new ADODB.Connection(); objRec = new ADODB.Recordset(); //establish the connection string and open the database connection strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" + "database=functional_test_data;option=3"; objCon.Open(strCon); //execute the SQL and return the recrodset of results objRec = objCon.Execute(strSQL, out missing, 0); //populate a two dinmensional object array with the results dataRows = objRec.GetRows(); //get a one dimensional array that can be placed into the Test Suite dropdown dataSuite = thinArray(dataRows); //close the recordset objRec.Close(); //close the database connection objCon.Close(); return dataSuite; }
override internal void LoadAll() { ADODB.Connection cnn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); ADOX.Catalog cat = new ADOX.Catalog(); // Open the Connection cnn.Open(dbRoot.ConnectionString, null, null, 0); cat.ActiveConnection = cnn; ADOX.Procedure proc = cat.Procedures[this.Procedure.Name]; // Retrieve Parameter information rs.Source = proc.Command as ADODB.Command; rs.Fields.Refresh(); Pervasive.PervasiveResultColumn resultColumn; if(rs.Fields.Count > 0) { int ordinal = 0; foreach(ADODB.Field field in rs.Fields) { resultColumn = this.dbRoot.ClassFactory.CreateResultColumn() as Pervasive.PervasiveResultColumn; resultColumn.dbRoot = this.dbRoot; resultColumn.ResultColumns = this; resultColumn.name = field.Name; resultColumn.ordinal = ordinal++; resultColumn.typeName = field.Type.ToString(); this._array.Add(resultColumn); } } cnn.Close(); }
private void load_leaders() { Conn.Close(); Conn.Open(); try { isini = true; isedit = true; string sql = ""; string sql1 = ""; txtpriv.Text = Gvar.frm_priv; sql = "select MOnth_code,Month_name from Month_Names order by Month_code "; SqlDataAdapter ada3 = new SqlDataAdapter(sql, Conn); DataTable dt3 = new DataTable("MOnth"); ada3.Fill(dt3); cmbmonth.DisplayMember = "Month_name"; cmbmonth.ValueMember = "MOnth_code"; cmbmonth.DataSource = dt3; //MessageBox.Show(DateTime.Now.Date.Month.ToString()); cmbmonth.SelectedValue = DateTime.Now.Date.Month; if (ADOconn.State == 0) { ADOconn.Open("Provider=SQLOLEDB;Initial Catalog= " + decoder.InitialCatalog + ";Data Source=" + decoder.DataSource + ";", decoder.UserID, decoder.Password, 0); } ADODB.Recordset rec = new ADODB.Recordset(); sql = "SELECT SALARY_AC FROM AC_OPTIONS WHERE ac_options.ID =1"; rec.Open(sql, ADOconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1); if (rec.RecordCount != 0) { txtsalacno.Text = rec.Fields[0].Value.ToString(); } isini = false; // dgv1.Columns[2].Width = 200; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public object[] db_access(string strSQL) { ADODB.Connection objCon; ADODB.Recordset objRec; object[,] dataRows; object[] dataSuite; string strCon; objCon = new ADODB.Connection(); objRec = new ADODB.Recordset(); //establish the connection string and open the database connection strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" + "database=functional_test_data;option=3"; objCon.Open(strCon); //execute the SQL and return the recrodset of results objRec = objCon.Execute(strSQL, out missing, 0); //populate a two dinmensional object array with the results dataRows = objRec.GetRows(); //get a one dimensional array that can be placed into the Test Suite dropdown dataSuite = thinArray(dataRows); //close the recordset objRec.Close(); //close the database connection objCon.Close(); return(dataSuite); }
private void Button_Click(object sender, RoutedEventArgs e) { //创建数据库文件 ADOX.Catalog catalog = new Catalog(); catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\test.mdb;Jet OLEDB:Engine Type=5"); Debug.WriteLine("DataBase created"); //建表 ADODB.Connection cn = new ADODB.Connection(); cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\test.mdb", null, null, -1); catalog.ActiveConnection = cn; ADOX.Table table = new ADOX.Table(); table.Name = "FirstTable"; ADOX.Column column = new ADOX.Column(); column.ParentCatalog = catalog; column.Name = "RecordId"; column.Type = DataTypeEnum.adInteger; column.DefinedSize = 9; column.Properties["AutoIncrement"].Value = true; table.Columns.Append(column, DataTypeEnum.adInteger, 9); table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null); table.Columns.Append("CustomerName", DataTypeEnum.adVarWChar, 50); table.Columns.Append("Age", DataTypeEnum.adInteger, 9); table.Columns.Append("Birthday", DataTypeEnum.adDate, 0); catalog.Tables.Append(table); cn.Close(); }
/// <summary> /// 删除表 /// </summary> /// <param name="strConnection"></param> /// <param name="strTableName"></param> public static void DeleteDBTable(string strConnection, string strTableName) { ADOX.Catalog catalog = new Catalog(); ADODB.Connection cn = new ADODB.Connection(); try { OleDbConnection conn = new OleDbConnection(strConnection); conn.Open(); cn.Open(strConnection, null, null, -1); catalog.ActiveConnection = cn; bool flag = dbutils.GetTables(conn, strTableName); if (flag)//判断表名是否存在 { catalog.Tables.Delete(strTableName); } //此处一定要关闭连接,否则添加数据时候会出错 catalog = null; Application.DoEvents(); cn.Close(); } catch (Exception ex) { loghelp.log.Fatal(ex.Message, ex); } }
public override TableField[] GetFieldMark(string tableName) { List <TableField> fields = new List <TableField>(); try { ADODB.Connection adodb_conn = new ADODB.Connection(); adodb_conn.Open(base.connector.ConnectionString, null, null, -1); ADOX.Catalog catalog = new ADOX.Catalog(); catalog.ActiveConnection = adodb_conn; ADOX.Table table = catalog.Tables[tableName]; foreach (ADOX.Column col in table.Columns) { string type = col.Type.ToString(); if (type.Contains('(')) { type = type.Substring(type.IndexOf('(')); } TableField field = new TableField() { Name = col.Name, Type = type, NoNull = false }; fields.Add(field); } Marshal.FinalReleaseComObject(catalog.ActiveConnection); Marshal.FinalReleaseComObject(catalog); return(fields.ToArray()); } catch (Exception e) { throw (e); } }
public override void SetFieldMark(string tableName, string tableMemo, TableField[] fields) { try { ADODB.Connection adodb_conn = new ADODB.Connection(); adodb_conn.Open(base.connector.ConnectionString, null, null, -1); ADOX.Catalog catalog = new ADOX.Catalog(); catalog.ActiveConnection = adodb_conn; ADOX.Table table = catalog.Tables[tableName]; foreach (TableField field in fields) { ADOX.Column col = table.Columns[field.Name]; } Marshal.FinalReleaseComObject(catalog.ActiveConnection); Marshal.FinalReleaseComObject(catalog); } catch (Exception e) { throw (e); } //--------------------- // 作者:重庆 - 传说 //来源:CSDN //原文:https://blog.csdn.net/zdb330906531/article/details/49420991 //版权声明:本文为博主原创文章,转载请附上博文链接! }
//创建数据表 public bool CreateAccessTable(string FilePath, string tableName, params ADOX.Column[] colums) { bool bolReturn = false; ADOX.Catalog clg = new Catalog(); //数据库文件存在 try { if (CreateAccess(FilePath) == true) { ADODB.Connection cn = new ADODB.Connection(); //连接已创建的数据库文件 cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FilePath, null, null, -1); clg.ActiveConnection = cn; //打开已创建的数据库文件 ADOX.Table table1 = new ADOX.Table(); table1.Name = tableName; foreach (var column in colums) { if (column.Name != null) { table1.Columns.Append(column); } } clg.Tables.Append(table1); cn.Close(); bolReturn = true; } }catch (Exception ex) { MessageBox.Show("创建失败\r\n" + ex.ToString(), "提示"); } return(bolReturn); }
public override IList <Column> GetTableColumns(IDbConnection connection, string schemaName, string tableName, string databaseInstanceName = null) { if (connection == null) { throw new ArgumentNullException("connection"); } if (tableName == null) { throw new ArgumentNullException("tableName"); } var columns = new List <Column>(); var cnn = new ADODB.Connection(); try { cnn.Open(connection.ConnectionString); var catalog = new Catalog(); catalog.ActiveConnection = cnn; foreach (ADOX.Table table in catalog.Tables) { if (_systemTablesList.Any( x => string.Equals(table.Name, x, StringComparison.InvariantCultureIgnoreCase))) { continue; } if (!string.Equals(table.Name, tableName)) { continue; } var tab = new Table(table.Name, MsAccess2003DatabaseServer.DefaultSchema); foreach (ADOX.Column column in table.Columns) { var col = GetColumn(column, tab); columns.Add(col); } return(columns); } } finally { try { cnn.Close(); } catch { } } return(columns); //_log.DebugFormat("Getting column for schema {0} and table {1} ...", schemaName, tableName); //var t = new Table(tableName, _defaultSchema); //var columns = GetTableColumnsDefault<OleDbType>(connection, t); //_log.DebugFormat("Retrieved {0} column(s).", columns.Count.ToString("#,0")); //return columns.OrderBy(x => x.Name).ToList(); }
private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs) { short x = 0; string strDBPath = null; Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); if (!string.IsNullOrEmpty(DataList1.BoundText)) { strDBPath = modRecordSet.serverPath + "month" + gMonth - this.cmbMonth.SelectedIndex + ".mdb"; if (fso.FileExists(strDBPath)) { var _with1 = cnnDBStatement; _with1.Provider = "MSDataShape"; cnnDBStatement.Open("Data Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strDBPath + ";User Id=liquid;Password=lqd;Jet OLEDB:System Database=" + modRecordSet.serverPath + "Secured.mdw"); SupplierStatement(ref Convert.ToInt32(DataList1.BoundText)); cnnDBStatement.Close(); } else { Interaction.MsgBox("There is no previous month statement for this Supplier", MsgBoxStyle.ApplicationModal + MsgBoxStyle.OkOnly + MsgBoxStyle.Information, _4PosBackOffice.NET.My.MyProject.Application.Info.Title); this.Close(); } } }
//在指定的Access数据库中创建配置的表格 public static bool CreateConfTable() { Catalog catalog = new Catalog(); ADODB.Connection cn = new ADODB.Connection(); try { cn.Open(DBLink); catalog.ActiveConnection = cn; Table table = new Table(); table.ParentCatalog = catalog; table.Name = CONF_TABLE; //字段 Column col = new Column(); col.ParentCatalog = catalog; col.Name = "id"; table.Columns.Append(col, DataTypeEnum.adVarWChar, 50); //默认数据类型和字段大小 table.Keys.Append("pk_id", KeyTypeEnum.adKeyPrimary, col, null, null); Column col2 = new Column(); col2.ParentCatalog = catalog; col2.Name = "bgtime"; col2.Attributes = ColumnAttributesEnum.adColNullable; //允许空值 table.Columns.Append(col2, DataTypeEnum.adDBTime); //默认数据类型和字段大小 catalog.Tables.Append(table); cn.Close(); logger.Info("完成创建" + CONF_TABLE + "表"); } catch (System.Exception ex) { //Trace.TraceWarning("Access连接打开失败", ex); logger.Error(ex, "创建" + CONF_TABLE + "表失败"); return(false); } return(true); }
//修改数据库密码 public void editDBPwd_B(string old_password, string new_password) { try { string fileName = Application.StartupPath + @"\source\StuContact.mdb";//数据库路径 string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Jet OLEDB:Database password="******"ALTER DATABASE PASSWORD " + new_password + " " + old_password; ADODB.Connection cn = new ADODB.Connection(); cn.Mode = ADODB.ConnectModeEnum.adModeShareExclusive;//以独占模式打开数据库,不然不能修改密码 cn.Open(conn, null, null, -1); // 执行 SQL 语句以更改密码 object num; cn.Execute(sql, out num, -1); cn.Close(); //开始修改配置文件 config.writeConfig_IsEditDBandAddPwd(true, new_password); MessageBox.Show("密码修改成功,请牢记您的密码", "修改提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("数据库密码未修改,因为:" + ex.Message, "提示", MessageBoxButtons.OK); } }
private void Form1_Load(object sender, EventArgs e) { String Sqlstr1, Sqlstr2; Cn = new ADODB.Connection(); Rscar = new ADODB.Recordset(); Rsuser = new ADODB.Recordset(); Cn.Provider = "Microsoft.Jet.Oledb.4.0"; Cn.ConnectionString = "DataBase\\Cars.mdb"; Cn.Open(); Sqlstr1 = "select * from Car"; Sqlstr2 = "select * from Customer"; Rscar.Open(Sqlstr1, Cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic); Rsuser.Open(Sqlstr2, Cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic); menu.Parent = tab; info.Parent = null; customer.Parent = null; modify.Parent = null; returnCar.Parent = null; Rscar.MoveFirst(); //Rsuser.MoveFirst(); }
public bool Execute(string sql) { bool stat = false; object obj; try { if (Connected() == true) { if (cnn == null) { cnn = new ADODB.Connection(); } if (cnn.State == 0) { cnn.Open(cnn_str, "", "", 0); } if (cnn.State == 1) { cnn.Execute(sql, out obj, 0); cnn.Close(); stat = true; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(stat); }
public static string ReadExcel(string FilePath, int C, int R) { ADODB.Connection conn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); string Sql = "Select * From [Sheet1$]"; //Select 宗地编码,土地类型,承包方名称,承包方编码 From [地块信息$] Order By 承包方编码,宗地编码 conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" + FilePath); rs.Open(Sql, conn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly, -1); object ary = rs.GetRows(); object[,] aa = (object[, ])ary; rs.Close(); conn.Close(); if ((string)aa[C - 1, R - 2] == null) { return(""); } return((string)aa[C - 1, R - 2]); }
private void menge_Produkt3_Button_Click(object sender, EventArgs e) { metroGrid3.Rows.Clear(); //Recordset ADODB.Connection cn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); try { cn.Open(cnStr); rs.Open("Select Artikel, Sum(Anzahl) as Anzahl_Menge From Listen where Endprodukt = 3 group by Artikel", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1); int i = 0; while (!rs.EOF) { metroGrid3.Rows.Add(); metroGrid3.Rows[i].Cells["Artikel_Mengen"].Value = Convert.ToInt32(rs.Fields["Artikel"].Value); metroGrid3.Rows[i].Cells["Anzahl_Menge"].Value = Convert.ToInt32(rs.Fields["Anzahl_Menge"].Value); rs.MoveNext(); i++; } rs.Close(); } catch (Exception fehler) { Console.WriteLine("Ein Fehler ist aufgetreten", fehler); //Try catch überprüfen.... } finally { cn.Close(); } }
public static void ReadDB(string tableName, string fileName) { string filePath = @"D:\xl2cad.mdb"; if (File.Exists(filePath)) { //select * into 建立 新的表。 //[[Excel 8.0;database= excel名].[sheet名] 如果是新建sheet表不能加$,如果向sheet里插入数据要加$. //sheet最多存储65535条数据。 ADODB.Connection cn = null; try { object ra = null; string sql = "select top 65535 * into [Excel 8.0;database=" + fileName + "].[" + tableName + "] from " + tableName; cn = new ADODB.Connection(); cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath, null, null, -1); cn.Execute(sql, out ra, -1); cn.Close(); System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cn); } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } finally { cn.Close(); System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cn); System.GC.Collect(); } } }
/// <summary> /// Upgrades a Version 1.0 database to Version 1.1. This upgrade is the /// addition of the field "TerminalParameters" to the table tblFunctionSet. /// </summary> /// <returns></returns> private static bool UpgradeDatabase() { try { ADODB.Connection con = new ADODB.Connection(); con.Open(ConnectionString, "", "", 0); Catalog dbCatalog = new Catalog(); dbCatalog.ActiveConnection = con; Table dbTable = dbCatalog.Tables["tblFunctionSet"]; dbTable.Columns.Append("TerminalParameters", ADOX.DataTypeEnum.adBoolean, 1); dbTable.Columns[dbTable.Columns.Count - 1].Properties["Default"].Value = "False"; con.Close(); } catch (Exception) { MessageBox.Show("Failed to correctly upgrade the database"); return(false); } // // If the upgrade succeeded, update the version value in the admin table return(UpdateField(1, "tblAdministration", "Description", GPEnums.DATABASE_VERSION)); }
public static bool TableExist(string dbName, string tblName, string pwd = "") { try { ADOX.Catalog cat = new ADOX.Catalog(); ADODB.Connection cn = new ADODB.Connection(); cn.Open(Provider + @"Data Source=" + dbName + ";" + Password + "=" + pwd); cat.ActiveConnection = cn; for (int i = 0; i < cat.Tables.Count; ++i) { ADOX.Table t = cat.Tables[i]; if (t.Name == tblName) { return(true); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return(false); } return(false); }
public static bool OpenAdoMysql(ADODB.Connection conn) { bool opened; // close the connection if it already exists CloseAdo(conn); try { // gwwd - nont here at start ... conn.DefaultDatabase = ""; //conn.ConnectionString = "Provider=MySQLProv;Data Source=webmpx; Persist Security Info = False"; //conn.ConnectionString = "Provider=MySQLProv;" + GetUserDatabaseConnection().ToString(); /* using (OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString)) { * connection.Open(); * */ conn.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString; conn.Mode = (ADODB.ConnectModeEnum)ADODB.CursorLocationEnum.adUseServer; conn.Open(); opened = true; } catch (Exception e) { // MyUtilities.MsgBox("Error in opening database connection: " + conn.ConnectionString + " (" + e.Message + ")"); opened = false; LogFiles logFiles = new LogFiles(); logFiles.ErrorLog(e); //throw new Exception(e.Message); } return(opened); }
private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'clientDBDataSet.ClientTable' table. You can move, or remove it, as needed. //this.clientTableTableAdapter.Fill(this.clientDBDataSet.ClientTable); Con = new ADODB.Connection(); Rs = new ADODB.Recordset(); //Connection calling partner object Provider, Path file, access string Con.Provider = Obj.MSAccessObj.Provider; Con.ConnectionString = Obj.MSAccessObj.PathFile; Con.Open(); //partnerObj.CAccess.AccessString = "select * from " in Class String accessStr; accessStr = Obj.MSAccessObj.AccessString + accessTableName; Rs.Open(accessStr, Con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic); // connection in sql DB cn = new System.Data.OleDb.OleDbConnection(); // A dataset for sql table ds = new DataSet(); //sqlCon.ConnectionString = Obj.MSSQLObj.DataSource + Obj.MSSQLObj.AttachedDB + Obj.MSSQLObj.IntSecurity; cn.ConnectionString = "Provider = SQLNCLI11.0;Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\ITD\\Term 3\\C#\\assignment\\assignment7\\AwareObject\\AwareObject\\AwareSQLDB.mdf;Integrated Security = SSPI;database=thingy"; cn.Open(); // Attempting to access Admin Table String sqlstr; sqlstr = Obj.MSSQLObj.SqlStr + sqlTableName; da = new System.Data.OleDb.OleDbDataAdapter(sqlstr, cn); da.Fill(ds, sqlTableName); RecordCount = ds.Tables[sqlTableName].Rows.Count; }
/// <summary> /// 在access数据库中创建表 /// </summary> /// <param name="filePath">数据库表文件全路径如D:\\NewDb.mdb 没有则创建 </param> /// <param name="tableName">表名</param> /// <param name="colums">ADOX.Column对象数组</param> public static bool CreateAccessTable(string filePath, string tableName, params ADOX.Column[] colums) { ADOX.Catalog catalog = new Catalog(); //数据库文件不存在则创建 if (!File.Exists(filePath)) { try { catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Jet OLEDB:Engine Type=5"); } catch (System.Exception ex) { return(false); } } ADODB.Connection cn = new ADODB.Connection(); cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath, null, null, -1); catalog.ActiveConnection = cn; ADOX.Table table = new ADOX.Table(); table.Name = tableName; foreach (var column in colums) { table.Columns.Append(column); } colums[0].ParentCatalog = catalog; colums[0].Properties["AutoIncrement"].Value = true; //设置自动增长 table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, colums[0], null, null); //定义主键 catalog.Tables.Append(table); cn.Close(); return(true); }
public static ADODB.Connection ConnectExchange(string Path) { ADODB.Connection Cnn = new ADODB.Connection(); Cnn.Provider = "msdaipp.dso"; Cnn.Mode = ADODB.ConnectModeEnum.adModeReadWrite; Cnn.Open(Path, "Namwah", "ParaW0rld", -1); return Cnn; }
public override IList <Table> GetTables(IDbConnection connection, string schemaName, string databaseInstanceName = null) { if (connection == null) { throw new ArgumentNullException("connection"); } var cnn = new ADODB.Connection(); try { var tables = new List <Table>(); cnn.Open(connection.ConnectionString); var catalog = new Catalog(); catalog.ActiveConnection = cnn; var viewNames = (catalog.Views.Cast <ADOX.View>().Select(view => view.Name)).ToList(); foreach (ADOX.Table table in catalog.Tables) { if (_systemTablesList.Any( x => string.Equals(table.Name, x, StringComparison.InvariantCultureIgnoreCase))) { continue; } if (viewNames.Any( x => string.Equals(table.Name, x, StringComparison.InvariantCultureIgnoreCase))) { continue; } tables.Add(new Table(table.Name, MsAccess2003DatabaseServer.DefaultSchema)); } return(tables); } finally { try { cnn.Close(); } catch { } } //var tblrestrictions = new[] {null, null, null, "TABLE"}; //var tables = new List<Table>(); //var olecon = (OleDbConnection) connection; //var dataTable = olecon.GetSchema("tables", tblrestrictions); //foreach (DataRow dataRow in dataTable.Rows) //{ // var tableName = (string) dataRow["TABLE_NAME"]; // tables.Add(new Table(tableName, MsAccess2003DatabaseServer.DefaultSchema)); //} //_log.DebugFormat("Retrieved {0} table(s).", tables.Count.ToString("#,0")); //return tables.OrderBy(x => x.Name).ToList(); }
public override IList <View> GetViews(IDbConnection connection, string schemaName, string databaseInstanceName = null) { if (connection == null) { throw new ArgumentNullException("connection"); } var cnn = new ADODB.Connection(); try { var views = new List <View>(); cnn.Open(connection.ConnectionString); var catalog = new Catalog(); catalog.ActiveConnection = cnn; foreach (ADOX.View view in catalog.Views) { if (_systemViewsList.Any( x => string.Equals(view.Name, x, StringComparison.InvariantCultureIgnoreCase))) { continue; } views.Add(new View(view.Name, MsAccess2003DatabaseServer.DefaultSchema)); } return(views); } finally { try { cnn.Close(); } catch { } } //if (connection == null) throw new ArgumentNullException("connection"); //var conn = connection as OleDbConnection; //if (conn == null) //{ // throw new Exception("Microsoft Access database requires OleDbConnection"); //} //var views = new List<View>(); //DataTable queries = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Views, null); //if (queries != null) //{ // foreach (DataRow row in queries.Rows) // { // var viewName = row["TABLE_NAME"].ToString(); // //var viewSql = row["VIEW_DEFINITION"].ToString(); // var view = new View(viewName, _defaultSchema); // views.Add(view); // } //} //return views.OrderBy(x => x.Name).ToList(); }
/// <summary> /// 新建mdb表,mdbHead是一个ArrayList,存储的是table表中的具体列名 /// </summary> /// <param name="mdbPath"></param> /// <param name="tableName"></param> /// <param name="mdbHead"></param> /// <returns></returns> private static bool CreateMDBTable(string tableName, ArrayList mdbHead) { //ADODB需添加com程序集 try { ADOX.CatalogClass cat = new ADOX.CatalogClass(); string sAccessConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbpath; ADODB.Connection cn = new ADODB.Connection(); cn.Open(sAccessConnection, null, null, 0); cat.ActiveConnection = cn; //新建一个表 ADOX.TableClass tbl = new ADOX.TableClass(); tbl.ParentCatalog = cat; tbl.Name = tableName; int size = mdbHead.Count; for (int i = 0; i < size; i++) { //增加一个文本字段 ADOX.ColumnClass col2 = new ADOX.ColumnClass(); ADOX.IndexClass ind2 = new ADOX.IndexClass(); col2.ParentCatalog = cat; col2.Name = mdbHead[i].ToString();//列的名称 col2.Properties["Jet OLEDB:Allow Zero Length"].Value = false; col2.DefinedSize = 50; if (i == 0) { // col2.Type = ADOX.DataTypeEnum.adSingle; // col2.Type = ADOX.DataTypeEnum.adInteger; // col2.Properties["AutoIncrement"].Value = true; tbl.Keys.Append("PrimaryKey", ADOX.KeyTypeEnum.adKeyPrimary, "通道"); } col2.SortOrder = ADOX.SortOrderEnum.adSortAscending; // col2.DefinedSize = 20; // col2.Type = ADOX.DataTypeEnum.adGUID; tbl.Columns.Append(col2, ADOX.DataTypeEnum.adWChar, 50); // tbl.Indexes.Append(col2 as ); // tbl.Columns.Append(col2, ADOX.KeyTypeEnum.adKeyPrimary, 500); } cat.Tables.Append(tbl); //这句把表加入数据库(非常重要) tbl = null; cat = null; cn.Close(); return(true); } catch (Exception t) { MessageBox.Show(t.Message); return(false); } }
//创建数据库 public void createDb(String versionNum) { ADOX.Catalog catalog = new ADOX.Catalog(); //String versionNum = extension.Text; try { catalog.Create(databaseCon + otherDbs + versionNum + ".mdb" + ";Jet OLEDB:Engine Type=5"); } catch { } ADODB.Connection cn = new ADODB.Connection(); cn.Open(databaseCon + otherDbs + versionNum + ".mdb", null, null, -1); catalog.ActiveConnection = cn; //创建表 ADOX.Table table = new ADOX.Table(); table.Name = "config1"; //创建列 ADOX.Column column = new ADOX.Column(); column.ParentCatalog = catalog; column.Name = "ID"; column.Type = DataTypeEnum.adInteger; column.DefinedSize = 9; column.Properties["AutoIncrement"].Value = true; table.Columns.Append(column, DataTypeEnum.adInteger, 9); // 设置为主键 table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null); table.Columns.Append("fileName", DataTypeEnum.adVarWChar, 0); table.Columns.Append("fileSize", DataTypeEnum.adInteger, 0); table.Columns.Append("createTime", DataTypeEnum.adDate, 0); table.Columns.Append("modifiedTime", DataTypeEnum.adDate, 0); table.Columns.Append("path", DataTypeEnum.adLongVarWChar, 0); table.Columns.Append("versionNum", DataTypeEnum.adInteger, 0); table.Columns.Append("updateMethod", DataTypeEnum.adVarWChar, 0); try { // 添加表 catalog.Tables.Append(table); } catch (Exception ex) { MessageBox.Show(ex.Message); } //此处一定要关闭连接,否则添加数据时候会出错 table = null; catalog = null; //Application.DoEvents(); cn.Close(); }
//Lagerbestand private void metroComboBox1_SelectedIndexChanged(object sender, EventArgs e) { ADODB.Connection cn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); try { cn.Open(cnStr); string periode = metroComboBox1.Text; if (periode == "0") { rs.Open("Select Startmenge, Artikelnummer, Startpreis From Artikelstammdaten", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1); int i = 0; metroGrid5.Rows.Clear(); while (!rs.EOF) { metroGrid5.Rows.Add(); metroGrid5.Rows[i].Cells["period"].Value = Convert.ToInt32(periode); metroGrid5.Rows[i].Cells["id"].Value = Convert.ToInt32(rs.Fields["Artikelnummer"].Value); metroGrid5.Rows[i].Cells["actualStock"].Value = Convert.ToInt32(rs.Fields["Startmenge"].Value); metroGrid5.Rows[i].Cells["actualPrice"].Value = Convert.ToDouble(rs.Fields["Startpreis"].Value); //metroGrid5.Rows[i].Cells["stockValue"].Value = ; rs.MoveNext(); i++; } } else { rs.Open("Select * From warehousestock_article where period ='" + periode + "'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1); int i = 0; metroGrid5.Rows.Clear(); while (!rs.EOF) { metroGrid5.Rows.Add(); metroGrid5.Rows[i].Cells["period"].Value = Convert.ToInt32(rs.Fields["period"].Value); metroGrid5.Rows[i].Cells["id"].Value = Convert.ToInt32(rs.Fields["id"].Value); metroGrid5.Rows[i].Cells["actualStock"].Value = Convert.ToInt32(rs.Fields["amount"].Value); metroGrid5.Rows[i].Cells["actualPrice"].Value = Convert.ToDouble(rs.Fields["price"].Value); metroGrid5.Rows[i].Cells["stockValue"].Value = Convert.ToDouble(rs.Fields["stockValue"].Value); rs.MoveNext(); i++; } } rs.Close(); } catch (Exception fehler) { Console.WriteLine("Ein Fehler ist aufgetreten", fehler); //Try catch überprüfen.... } finally { cn.Close(); } }
public static void NewDatabase() { //CComLibrary.GlobeVal.filesave.SampleDefaultName if (System.IO.Directory.Exists(Application.StartupPath + "\\mdb") == true) { System.IO.Directory.CreateDirectory(Application.StartupPath + "\\mdb"); } if (File.Exists(Application.StartupPath + "\\mdb\\" + CComLibrary.GlobeVal.filesave.methodname + ".mdb") == true) { File.Delete(Application.StartupPath + "\\mdb\\" + CComLibrary.GlobeVal.filesave.methodname + ".mdb"); } ADOX.Catalog catalog = new Catalog(); catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\mdb\\" + CComLibrary.GlobeVal.filesave.methodname + ".mdb;" + "Jet OLEDB:Engine Type=5"); ADODB.Connection cn = new ADODB.Connection(); cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\mdb\\" + CComLibrary.GlobeVal.filesave.methodname + ".mdb", null, null, -1); catalog.ActiveConnection = cn; ADOX.Table table = new ADOX.Table(); table.Name = "FirstTable"; ADOX.Column column = new ADOX.Column(); column.ParentCatalog = catalog; column.Name = "RecordId"; column.Type = DataTypeEnum.adInteger; column.DefinedSize = 9; column.Properties["AutoIncrement"].Value = true; table.Columns.Append(column, DataTypeEnum.adInteger, 9); table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null); for (int i = 0; i < CComLibrary.GlobeVal.filesave.mdatabaseitemselect.Count; i++) { column = new ADOX.Column(); column.Name = CComLibrary.GlobeVal.filesave.mdatabaseitemselect[i].Name; column.Attributes = ColumnAttributesEnum.adColNullable; table.Columns.Append(column, DataTypeEnum.adVarWChar, 80); } // table.Columns.Append("CustomerName", DataTypeEnum.adVarWChar, 50); // table.Columns.Append("Age", DataTypeEnum.adInteger, 9); // table.Columns.Append("生日", DataTypeEnum.adVarWChar, 80); catalog.Tables.Append(table); cn.Close(); }
/// <summary> /// 创建数据库表 /// </summary> /// <param name="strConnection"></param> /// <param name="strTableName"></param> /// <param name="listColumns"></param> public static void CreatDBTable(string strConnection, string strTableName, List <string> listColumns) { ADOX.Catalog catalog = new Catalog(); ADODB.Connection cn = new ADODB.Connection(); strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + strConnection; OleDbConnection conn = new OleDbConnection(strConnection); try { conn.Open(); cn.Open(strConnection, null, null, -1); catalog.ActiveConnection = cn; if (string.IsNullOrEmpty(strTableName)) { loghelp.log.Error("表名不能为空!"); return; } bool flag = db.dbutils.GetTables(conn, strTableName); if (!flag)//判断表名是否存在 { ADOX.Table table = new ADOX.Table(); table.Name = strTableName; ADOX.Column column = new ADOX.Column(); column.ParentCatalog = catalog; column.Name = "id"; column.Type = ADOX.DataTypeEnum.adInteger; column.DefinedSize = 50; column.Properties["AutoIncrement"].Value = true; table.Columns.Append(column, DataTypeEnum.adInteger, 50); table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null); foreach (string strColumns in listColumns) { table.Columns.Append(strColumns, DataTypeEnum.adVarWChar, 50); table.Columns[strColumns].Attributes = ColumnAttributesEnum.adColNullable; } catalog.Tables.Append(table); //此处一定要关闭连接,否则添加数据时候会出错 table = null; catalog = null; } } catch (Exception ex) { loghelp.log.Fatal(ex.Message, ex); } finally { conn.Close(); cn.Close(); } }
public static void LoadItem() { string partPath = "http://nwszmail/public/namwah/Parts2/Parts/"; ADODB.Connection cn = new ADODB.Connection(); ADODB.Record rst; cn.Provider = "msdaipp.dso"; cn.CommandTimeout = 3600; cn.Mode = ADODB.ConnectModeEnum.adModeReadWrite; cn.Open(partPath, "Namwah", "ParaW0rld", -1); }
/// <summary> /// Returns the correct ADO ODBC connection for the given service /// </summary> /// <param name="strServiceName"></param> /// <returns>ADODB.Connection</returns> public static ADODB.Connection GetAdoOdbcConnection(string strServiceName) { string strOdbcConnectionString; CXSCRIPTLib.GlobalFunctions globalFunctions = new CXSCRIPTLib.GlobalFunctions(); strOdbcConnectionString = globalFunctions.GetODBCConnectionString(strServiceName); ADODB.Connection connection = new ADODB.Connection(); connection.Open(strOdbcConnectionString, null, null, 0); return(connection); }
public ViewReport(string titleReport, string rptFile, string querySql, string[] paramName, object[] paramValues, bool staticPrinter) { InitializeComponent(); this.Text = titleReport; CRAXDDRT.Application crxApp = new CRAXDDRT.Application(); CRAXDDRT.Report report = new CRAXDDRT.Report(); ADODB.Connection conn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient; string connstr = "Provider=SQLOLEDB;Data Source=" + SqlHelper.IPAddress + ";Initial Catalog=" + SqlHelper.DatabaseName + ";User Id=" + SqlHelper.UserID + ";Password="******";"; string reportFile = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) + "/Report/" + rptFile; try { conn.Open(connstr, null, null, 0); report = crxApp.OpenReport(reportFile, OpenReportMethod.OpenReportByDefault); report.DiscardSavedData(); if (paramName != null) { for (int i = 0; i < paramName.Length; i++) { report.ParameterFields.GetItemByName(paramName[i], null).AddCurrentValue(paramValues[i]); } } rs.Open( querySql, // SQL statement / table,view name / // stored procedure call / file name conn, // Connection / connection string ADODB.CursorTypeEnum.adOpenForwardOnly, // Cursor type. (forward-only cursor) ADODB.LockTypeEnum.adLockOptimistic, // Lock type. (locking records only // when you call the Update method. (int)ADODB.CommandTypeEnum.adCmdText); /* For Execute StoreProcedure */ // rs.Open(querySql, conn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1); report.Database.SetDataSource(rs, 3, 1); if (staticPrinter) { string printerName = Configurations.getPrinter(); report.SelectPrinter("", printerName, ""); //report.PrintOut(false, 1, true, 1, 200); } this.axCrystalActiveXReportViewer1.ReportSource = report; this.axCrystalActiveXReportViewer1.ViewReport(); } catch (Exception ex) { //this.Dispose(); //this.Close(); MessageBox.Show(ex.Message); } }
private void metroComboBox4_SelectedIndexChanged(object sender, EventArgs e) { ADODB.Connection cn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); try { cn.Open(cnStr); string periode = metroComboBox4.Text; if (periode == "0") { rs.Open("Select * From summary", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1); metroGrid4.Rows.Clear(); int i = 0; while (!rs.EOF) { metroGrid1.Rows.Add(); metroGrid1.Rows[i].Cells["Gewinn"].Value = rs.Fields["profit_current"].Value; metroGrid1.Rows[i].Cells["GewinnDurchschnitt"].Value = rs.Fields["profit_average"].Value; metroGrid1.Rows[i].Cells["GewinnGesamt"].Value = rs.Fields["profit_all"].Value; rs.MoveNext(); ++i; } //i = 0; } else { rs.Open("Select * From summary", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1); metroGrid4.Rows.Clear(); int i = 0; while (!rs.EOF) { metroGrid1.Rows.Add(); metroGrid1.Rows[i].Cells["Gewinn"].Value = rs.Fields["profit_current"].Value; metroGrid1.Rows[i].Cells["GewinnDurchschnitt"].Value = rs.Fields["profit_average"].Value; metroGrid1.Rows[i].Cells["GewinnGesamt"].Value = rs.Fields["profit_all"].Value; rs.MoveNext(); ++i; } //i = 0; } rs.Close(); } catch (Exception fehler) { Console.WriteLine("Ein Fehler ist aufgetreten", fehler); //Try catch überprüfen.... } finally { cn.Close(); } }
/// <summary> /// 建立 优惠劵 数据库 /// </summary> public static void Coupons_InitDataBase() { // string sqlstr = "INSERT INTO WX_Coupons(CUserName, CUserPhone, CUserqq, WXOpenID) VALUES (N'" + CUserName + "',N'" + CUserPhone + "',N'" + CUserqq + "',N'" + Session["WXOpenID"] + "')"; string PathDataBase = System.IO.Path.Combine(SYSTEMDIR, "USER_DIR\\SYSUSER\\Coupons\\db.dll");//"USER_DIR\\SYSUSER\\SYSSET\\" + if (System.IO.File.Exists(PathDataBase) == true ) { return; } try { ADOX.Catalog catalog = new Catalog(); catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PathDataBase + ";Jet OLEDB:Engine Type=5"); ADODB.Connection cn = new ADODB.Connection(); cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + PathDataBase, null, null, -1); catalog.ActiveConnection = cn; if (true) { ADOX.Table table = new ADOX.Table(); table.Name = "WX_Coupons"; ADOX.Column column = new ADOX.Column(); column.ParentCatalog = catalog; column.Name = "WXOpenID"; column.Type = DataTypeEnum.adInteger; column.DefinedSize = 7; column.Properties["AutoIncrement"].Value = true; table.Columns.Append(column, DataTypeEnum.adInteger, 7); table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null); // string sqlstr = "INSERT INTO WX_Coupons(CUserName, CUserPhone, CUserqq, WXOpenID) VALUES (N'" + CUserName + "',N'" + CUserPhone + "',N'" + CUserqq + "',N'" + Session["WXOpenID"] + "')"; table.Columns.Append("CUserName", DataTypeEnum.adVarWChar, 200); table.Columns.Append("CUserPhone", DataTypeEnum.adVarWChar, 200); table.Columns.Append("CUserqq", DataTypeEnum.adVarWChar, 200); catalog.Tables.Append(table); } cn.Close(); } catch { } }
public Boolean CreateTable(String tableName, params ASColumn[] columns) { if (!CheckParams()) throw new ArgumentNullException("请先绑定文件名"); if (!File.Exists(base.FileName)) throw new ArgumentNullException("文件不存在"); if (String.IsNullOrEmpty(tableName)) return false; try { ADOX.Catalog catalog = new Catalog(); ADODB.Connection conn = new ADODB.Connection(); conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + base.FileName, null, null, -1); catalog.ActiveConnection = conn; ADOX.Table table = new Table(); table.Name = tableName; for (int i = 0; i < columns.Length; i++) { ADOX.Column column = new Column(); column.ParentCatalog = catalog; column.Name = columns[i].Name; column.Type = columns[i].Type; column.Attributes = columns[i].Attribute; column.DefinedSize = columns[i].DefinedSize; table.Columns.Append(column, column.Type, column.DefinedSize); if (columns[i].Key != null) table.Keys.Append(columns[i].Name + columns[i].Key.Type, columns[i].Key.Type, column, null, null); } catalog.Tables.Append(table); conn.Close(); return true; } catch { return false; } }
private static void AddTable(OleDbConnectionStringBuilder csb) { // check if table exists var con = new ADODB.Connection(); con.Open(csb.ToString()); var db = new ADOX.Catalog(); db.ActiveConnection = con; try { var table = db.Tables[_logFileProcessor.TableName]; } catch (COMException) { db.Tables.Append(_logFileProcessor.GetTable()); } finally { con.Close(); } }
public static string[] GetTableExcel(string strFileName) { string[] strTables = new string[100]; Catalog oCatlog = new Catalog(); ADOX.Table oTable = new ADOX.Table(); ADODB.Connection oConn = new ADODB.Connection(); oConn.Open("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + strFileName + "; Extended Properties = \"Excel 8.0;HDR=Yes;IMEX=1\";", "", "", 0); oCatlog.ActiveConnection = oConn; if (oCatlog.Tables.Count > 0) { int item = 0; foreach (ADOX.Table tab in oCatlog.Tables) { if (tab.Type == "TABLE") { strTables[item] = tab.Name; item++; } } } return strTables; }
private object getMasterDB() { object functionReturnValue = null; // ERROR: Not supported in C#: OnErrorStatement //UPGRADE_WARNING: Couldn't resolve default property of object getMasterDB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' functionReturnValue = true; cnnDBmaster = new ADODB.Connection(); cnnDBmaster.Open("4posMaster"); //gMasterPath = Split(Split(cnnDBmaster.ConnectionString, ";DBQ=")(1), ";")(0) //gMasterPath = Split(LCase(gMasterPath), "4posmaster.mdb")(0) ' //win 7 Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); Scripting.TextStream textstream = default(Scripting.TextStream); string lString = null; if (Win7Ver() == true) { //If fso.FileExists("C:\4POS\4POSWinPath.txt") Then // Set textstream = fso.OpenTextFile("C:\4POS\4POSWinPath.txt", ForReading, True) // lString = textstream.ReadAll // serverPath = lString '& "pricing.mdb" //Else // serverPath = "C:\4POSServer\" '"pricing.mdb" //End If gMasterPath = "c:\\4posmaster\\"; //UPGRADE_WARNING: Couldn't resolve default property of object getMasterDB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' functionReturnValue = true; return functionReturnValue; } //win 7 gMasterPath = Strings.Split(Strings.Split(cnnDBmaster.ConnectionString, ";DBQ=")[1], ";")[0]; gMasterPath = Strings.Split(Strings.LCase(gMasterPath), "4posmaster.mdb")[0]; return functionReturnValue; openConnection_Error: // //UPGRADE_WARNING: Couldn't resolve default property of object getMasterDB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' functionReturnValue = false; return functionReturnValue; }
private void linkTables() { //catalogs contain all the tables that exist in the database (or are linked there). //need one for JCMS (access interface) for a destination and one for mysql (source) ADOX.Catalog catJCMS = new ADOX.Catalog(); ADOX.Catalog catMySQL = new ADOX.Catalog(); //connections allow you to read all tables into catalogs, need one for JCMS to say where tables are supposed to go //and one for MySQL to say where connections are coming from ADODB.Connection conJCMS = new ADODB.Connection(); ADODB.Connection conMySQL = new ADODB.Connection(); string userDSN = "JCMS" + host + databaseName; try { //STEP 1: connect to JCMS interface string strConx = "Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=True;Data Source=" + interfacePath + ";"; conJCMS.Mode = ADODB.ConnectModeEnum.adModeReadWrite; conJCMS.Open(strConx, "", "", 0); //STEP 1.A.: Create catalog for JCMS catJCMS.ActiveConnection = conJCMS; //STEP 2: CREATE USER DSN String strAttributes = string.Format("DSN={0};", userDSN); strAttributes = strAttributes + "Database=" + databaseName + ";"; strAttributes = strAttributes + string.Format("Description=DSN for {0}:{1};", host, databaseName); strAttributes = strAttributes + "Server=" + host + ";"; strAttributes = strAttributes + "User="******";"; strAttributes = strAttributes + "Password="******";"; IntPtr please = new IntPtr(0); bool DSNSuccess = SQLConfigDataSource(please, 1, "MySQL ODBC 3.51 Driver", strAttributes); if (!DSNSuccess) { WriteOutput("DSN Could not be created, could be a permissions issue, or ODBC driver is not properly installed. Tables will have to be linked manually."); } else { WriteOutput("DSN created successfully"); //STEP 3: open mysql connection using user dsn created above //string strConxString = "Provider=MSDASQL;" + "Driver=" + "MySQL ODBC 3.51 Driver" + ";" + "Server=" + host + ";" + "UID=" + username + ";" + "PWD=" + password + ";" + "Port=" + port; string strConxString = string.Format("Driver={0};Server={1};Database={2};Uid={3};Pwd={4};", "MySQL ODBC 3.51 Driver", host, databaseName, username, password); conMySQL.Open(strConxString, username, password, 0); catMySQL.ActiveConnection = conMySQL; ADOX.Table tblLink; //create links from MySQL to JCMS. foreach (ADOX.Table tblLoop in catMySQL.Tables) { tblLink = new ADOX.Table(); tblLink.Name = tblLoop.Name; tblLink.ParentCatalog = catJCMS; tblLink.Properties["Jet OLEDB:Link Datasource"].Value = interfacePath; tblLink.Properties["Jet OLEDB:Link Provider String"].Value = "ODBC;DATABASE=" + databaseName + ";DSN=" + userDSN +";OPTION=0;UID=" + username + ";PWD=" + password + ";PORT=" + port + ";SERVER=" + host + ";"; tblLink.Properties["Jet OLEDB:Remote Table Name"].Value = tblLoop.Name; tblLink.Properties["Jet OLEDB:Create Link"].Value = true; tblLink.Properties["Jet OLEDB:Cache Link Name/Password"].Value = true; catJCMS.Tables.Append(tblLink); WriteOutput(string.Format("Table {0} successfully linked.", tblLoop.Name)); } if (programVariables.getInstall()) { WriteOutput("Install process complete, tables successfully linked."); } else { WriteOutput("Upgrade process complete, tables successfully linked."); } } } catch (Exception e) { WriteOutput("The following error occurred when trying to relink tables: " + e.Message + " This step will have to be completed manually. For help please visit our FAQs page at http://colonymanagement.jax.org/support-2/faqs/ " + "or our forums at http://community.jax.org/jcms_discussion_forum/default.aspx"); } }
static void Main(string[] args) { ADODB.Connection conn = null; ADODB.Recordset rs = null; try { //////////////////////////////////////////////////////////////////////////////// // 连接数据源. // Console.WriteLine("正在连接数据库 ..."); // 获取连接字符串 string connStr = string.Format("Provider=SQLOLEDB;Data Source={0};Initial Catalog={1};Integrated Security=SSPI", ".\\sqlexpress", "SQLServer2005DB"); // 打开连接 conn = new ADODB.Connection(); conn.Open(connStr, null, null, 0); //////////////////////////////////////////////////////////////////////////////// // 编写并执行ADO命令. // 可以是SQL指令(SELECT/UPDATE/INSERT/DELETE),或是调用存储过程. // 此处是一个INSERT命令示例. // Console.WriteLine("将一条记录插入表CountryRegion中..."); // 1. 生成一个Command对象 ADODB.Command cmdInsert = new ADODB.Command(); // 2. 将连接赋值于命令 cmdInsert.ActiveConnection = conn; // 3. 设置命令文本 // SQL指令或者存储过程名 cmdInsert.CommandText = "INSERT INTO CountryRegion(CountryRegionCode, Name, ModifiedDate)" + " VALUES (?, ?, ?)"; // 4. 设置命令类型 // ADODB.CommandTypeEnum.adCmdText 用于普通的SQL指令; // ADODB.CommandTypeEnum.adCmdStoredProc 用于存储过程. cmdInsert.CommandType = ADODB.CommandTypeEnum.adCmdText; // 5. 添加参数 // CountryRegionCode (nvarchar(20)参数的添加 ADODB.Parameter paramCode = cmdInsert.CreateParameter( "CountryRegionCode", // 参数名 ADODB.DataTypeEnum.adVarChar, // 参数类型 (nvarchar(20)) ADODB.ParameterDirectionEnum.adParamInput, // 参数类型 20, // 参数的最大长度 "ZZ"+DateTime.Now.Millisecond); // 参数值 cmdInsert.Parameters.Append(paramCode); // Name (nvarchar(200))参数的添加 ADODB.Parameter paramName = cmdInsert.CreateParameter( "Name", // 参数名 ADODB.DataTypeEnum.adVarChar, // 参数类型 (nvarchar(200)) ADODB.ParameterDirectionEnum.adParamInput, // 参数传递方向 200, // 参数的最大长度 "Test Region Name"); // 参数值 cmdInsert.Parameters.Append(paramName); // ModifiedDate (datetime)参数的添加 ADODB.Parameter paramModifiedDate = cmdInsert.CreateParameter( "ModifiedDate", // 参数名 ADODB.DataTypeEnum.adDate, // 参数类型 (datetime) ADODB.ParameterDirectionEnum.adParamInput, // 参数传递方向 -1, // 参数的最大长度 (datetime忽视该值) DateTime.Now); // 参数值 cmdInsert.Parameters.Append(paramModifiedDate); // 6. 执行命令 object nRecordsAffected = Type.Missing; object oParams = Type.Missing; cmdInsert.Execute(out nRecordsAffected, ref oParams, (int)ADODB.ExecuteOptionEnum.adExecuteNoRecords); //////////////////////////////////////////////////////////////////////////////// // 使用Recordset对象. // http://msdn.microsoft.com/en-us/library/ms681510.aspx // Recordset表示了数据表中记录或执行命令获得的结果的集合。 // 在任何时候, Recordset对象都指向集合中的单条记录,并将 // 该记录作为它的当前记录。 // Console.WriteLine("列出表CountryRegion中的所有记录"); // 1. 生成Recordset对象 rs = new ADODB.Recordset(); // 2. 打开Recordset对象 string strSelectCmd = "SELECT * FROM CountryRegion"; // WHERE ... rs.Open(strSelectCmd, // SQL指令/表,视图名 / // 存储过程调用 /文件名 conn, // 连接对象/连接字符串 ADODB.CursorTypeEnum.adOpenForwardOnly, // 游标类型. (只进游标) ADODB.LockTypeEnum.adLockOptimistic, // 锁定类型. (仅当需要调用 // 更新方法时,才锁定记录) (int)ADODB.CommandTypeEnum.adCmdText); // 将第一个参数视为SQL命令 // 或存储过程. // 3. 通过向前移动游标列举记录 // 移动到Recordset中的第一条记录 rs.MoveFirst(); while (!rs.EOF) { // 当在表中定义了一个可空字段,需要检验字段中的值是否为DBNull.Value. string code = (rs.Fields["CountryRegionCode"].Value == DBNull.Value) ? "(DBNull)" : rs.Fields["CountryRegionCode"].Value.ToString(); string name = (rs.Fields["Name"].Value == DBNull.Value) ? "(DBNull)" : rs.Fields["Name"].Value.ToString(); DateTime modifiedDate = (rs.Fields["ModifiedDate"].Value == DBNull.Value) ? DateTime.MinValue : (DateTime)rs.Fields["ModifiedDate"].Value; Console.WriteLine(" {2} \t{0}\t{1}", code, name, modifiedDate.ToString("yyyy-MM-dd")); // 移动到下一条记录 rs.MoveNext(); } } catch (Exception ex) { Console.WriteLine("应用程序出现错误: {0}", ex.Message); if (ex.InnerException != null) Console.WriteLine("描述: {0}", ex.InnerException.Message); } finally { //////////////////////////////////////////////////////////////////////////////// // 退出前清理对象. // Console.WriteLine("正在关闭连接 ..."); // 关闭record set,当它处于打开状态时 if (rs != null && rs.State == (int)ADODB.ObjectStateEnum.adStateOpen) rs.Close(); // 关闭数据库连接,当它处于打开状态时 if (conn != null && conn.State == (int)ADODB.ObjectStateEnum.adStateOpen) conn.Close(); } }
/// <summary> /// 创建新的信息数据库 /// </summary> private void CreatDb() { string con = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=dac.accdb"; ADOX.Catalog catalog = new Catalog(); catalog.Create(con);//创建新的数据库 catalog.ActiveConnection(); ADODB.Connection connection = new ADODB.Connection(); connection.Open(con, null, null, -1); //新建主体信息数据表 ADOX.Table table = new Table(); table.Name = "主体信息表"; ADOX.Column subjectName = new Column();//主体名称 subjectName.Name = "主体名称"; ADOX.Column pwd = new Column();//主体登录密码 pwd.Name = "密码"; ADOX.Column SubjectRegisterTime = new Column();//主体登录密码 SubjectRegisterTime.Name = "注册时间"; table.Columns.Append(subjectName);//将列添加到表中 table.Columns.Append(pwd); table.Columns.Append(SubjectRegisterTime); catalog.Tables.Append(table); //新建角色信息数据表 table = new Table(); table.Name = "角色信息表"; ADOX.Column RoleName = new Column();//角色名称 RoleName.Name = "角色名称"; ADOX.Column RoleRegisterTime= new Column();//角色注册时间 RoleRegisterTime.Name = "创建时间"; table.Columns.Append(RoleName);//将列添加到表中 table.Columns.Append(RoleRegisterTime); catalog.Tables.Append(table); //新建角互斥色信息数据表 table = new Table(); table.Name = "互斥角色信息表"; ADOX.Column ExclusionRoleName = new Column();//角色名称 ExclusionRoleName.Name = "角色1名称"; ADOX.Column ExclusionRoleName1 = new Column();//角色名称 ExclusionRoleName1.Name = "角色2名称"; table.Columns.Append(ExclusionRoleName);//将列添加到表中 table.Columns.Append(ExclusionRoleName1); catalog.Tables.Append(table); //新建角色关系信息数据表 table = new Table(); table.Name = "角色关系信息表"; ADOX.Column FatherRoleName = new Column();//角色名称 FatherRoleName.Name = "父角色名称"; ADOX.Column ChildRoleName = new Column();//角色名称 ChildRoleName.Name = "子角色名称"; table.Columns.Append(FatherRoleName);//将列添加到表中 table.Columns.Append(ChildRoleName); catalog.Tables.Append(table); //新建权限信息表 table = new Table(); table.Name = "权限信息表"; ADOX.Column PermissionName = new Column();//权限名称 PermissionName.Name = "权限名称"; ADOX.Column PermissionRegisterTime = new Column();//权限创建注册时间 PermissionRegisterTime.Name = "创建时间"; table.Columns.Append(PermissionName);//将列添加到表中 table.Columns.Append(PermissionRegisterTime); catalog.Tables.Append(table); //新建用户角色指派信息表 table = new Table(); table.Name = "用户-角色指派信息表"; ADOX.Column UserName = new Column();//用户名称 UserName.Name = "用户名称"; RoleName = new Column();//角色名称 RoleName.Name = "角色名称"; table.Columns.Append(UserName);//将列添加到表中 table.Columns.Append(RoleName); catalog.Tables.Append(table); //新建角色到权限的指派信息表 table = new Table(); table.Name = "角色-权限指派信息表"; RoleName = new Column();//角色名称 RoleName.Name = "角色名称"; PermissionName = new Column();//权限名称 PermissionName.Name = "权限名称"; table.Columns.Append(RoleName); table.Columns.Append(PermissionName); catalog.Tables.Append(table); //新建注册管理表 table = new Table(); table.Name = "注册管理表"; ADOX.Column subject_Name1 = new Column();//客体名称 subject_Name1.Name = "主体名称"; ADOX.Column time = new Column();//客体名称 time.Name = "注册时间"; ADOX.Column pwd1 = new Column();//客体名称 pwd1.Name = "密码"; table.Columns.Append(subject_Name1); table.Columns.Append(time); table.Columns.Append(pwd1); catalog.Tables.Append(table); connection.Close();//关闭连接 }
public static bool openConsReport(ref string strL) { bool functionReturnValue = false; string strTable = null; bool createDayend = false; string strDBPath = null; // ERROR: Not supported in C#: OnErrorStatement createDayend = false; cnnDBConsReport = new ADODB.Connection(); strDBPath = modRecordSet.StrLocRep + "report" + My.MyProject.Forms.frmMenu.lblUser.Tag + ".mdb"; cnnDBConsReport.Open("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source= " + strDBPath + ";"); openConnection_Error: functionReturnValue = false; Interaction.MsgBox(Err().Number + " " + Err().Description + " " + Err().Source + Constants.vbCrLf + Constants.vbCrLf + " openConsReport object has not been made."); return functionReturnValue; }
public static void tstBrowser(string pth, string datSource, string steName, string tstName, int radnum, string baseURL, ref string[,] tstResult, out int fndExcep, out int fnlFail) { testname = tstName; int vfyFunc; int eleNum; int maxCols; int stpCount; int itmCount; int tstFail; char chr = Convert.ToChar(34); object[,] tmpArray; string[] outArray; string[] lstTest; string[] dbArray; string[,] dataArray; string[,] rsltArray; string argID; string functionID; string getNeg; string nmFunc; string step; string strCon; string strSQL; string tstID; string xlPath; ADODB.Connection objCon; ADODB.Recordset objRec; TestSuite lstObject; getNeg = ""; tstFail = 0; fnlFail = 0; fndExcep = 0; DateTime tmp = DateTime.Now; //date-time at the time of test running vfyFunc = 0; rsltArray = new string[1, 6]; //open browser based on selection on the GUI tstObject tstObj = new tstObject(radnum); //TextFileOps.Write(pth, "<li>", 100); switch (datSource) { case "DB": { //db connection string strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" + "database=functional_test_data;option=3"; //database connections objects objCon = new ADODB.Connection(); objRec = new ADODB.Recordset(); //open the connection to the database objCon.Open(strCon); //SQL to execute strSQL = "SELECT id FROM test WHERE name = '" + tstName + "'"; //open recordset and get test id with SQL objRec.Open(strSQL, objCon); //set test id to a string variable tmpArray = objRec.GetRows(); tstID = Convert.ToString(tmpArray[0, 0]); //close the recordset objRec.Close(); //SQL to execute strSQL = "SELECT COUNT(*) FROM step WHERE test_id = '" + tstID + "'"; //open recordset and get the number of stepsto execute with SQL objRec.Open(strSQL, objCon); //get the count value from the recordset and convert to an int fpor use in the step loop tmpArray = objRec.GetRows(); stpCount = Convert.ToInt32(tmpArray[0, 0]); //close the recordset objRec.Close(); //set up a for loop to run all steps in a test for (int stp = 0; stp < stpCount; stp++) { if (stp == 23) stp = 23; step = "Step " + Convert.ToString(stp + 1); //SQL to execute strSQL = "SELECT function_id, argument_set_id FROM step WHERE (test_id = '" + tstID + "') AND (number = " + (stp + 1) + ")"; //open recordset and get all the ids necessary for this step objRec.Open(strSQL, objCon); tmpArray = objRec.GetRows(); //set the function id functionID = Convert.ToString(tmpArray[0, 0]); //set the hash string for the argument set argID = Convert.ToString(tmpArray[1, 0]); //close the recordset objRec.Close(); //get the function name strSQL = "SELECT function_name FROM function WHERE id = '" + functionID + "'"; objRec.Open(strSQL, objCon); tmpArray = objRec.GetRows(); //set the function name variable nmFunc = Convert.ToString(tmpArray[0, 0]); //close the recordset objRec.Close(); // get the number of argments to be set to the application strSQL = "SELECT COUNT(*) FROM argument WHERE argument_set_id = '" + argID + "'"; objRec.Open(strSQL, objCon); tmpArray = objRec.GetRows(); //set the itmCount varable itmCount = Convert.ToInt32(tmpArray[0, 0]); //close the recordset objRec.Close(); if (itmCount > 0) { //set the array size for the inArray parameter of the drive function dbArray = new string[itmCount]; //set the array with blank values for (int x = 0; x < itmCount; x++) dbArray[x] = String.Empty; //get the argument data from the database and populate into the dbArray strSQL = "SELECT value FROM argument WHERE argument_set_id = '" + argID + "' ORDER BY seq ASC"; objRec.Open(strSQL, objCon); tmpArray = objRec.GetRows(); //close the recordset objRec.Close(); for (int stpData = 0; stpData < tmpArray.Length; stpData++) { if (stpData != tmpArray.Length) dbArray[stpData] = Convert.ToString(tmpArray[0, stpData]); } } else { dbArray = new string[1]; dbArray[0] = ""; } //call driveFunction to execute the step noted in dataArray[tstSuite. 0] TextFileOps.Write(pth, "<li>", 100); //initialize anm array to hold all of the test results that wiill be written to the results file tstResult = new string[1, 9]; //pass the appropriate vars to the drivefunction tstObj.driveFunction(tstObj, nmFunc, step, dbArray, baseURL, datSource, pth, ref getNeg, ref tstResult, out fndExcep, out tstFail); for (int x = 0; x < tstResult.GetLength(0); x++) { TextFileOps.Write(pth, "<div>", 100); if (fndExcep != -1) { if (tstResult[x, 0] == "verify") { switch (tstResult[x, 1].Trim()) { case "button": Recorder.btnVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], pth, getNeg); break; case "dropdown": Recorder.dropdownListVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 5], tstResult[x, 3], pth, getNeg); break; case "field": Recorder.fldVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "grades": Recorder.gradeVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], tstResult[x, 6], tstResult[x, 7], tstResult[x, 8], pth); break; case "image": Recorder.imgVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "link": Recorder.lnkVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "table": Recorder.tblVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], pth, getNeg); break; case "text": case "field text": Recorder.txtVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "outcome": Recorder.outcomeVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], tstResult[x, 6], tstResult[x, 7], tstResult[x, 8], pth); break; case "percentage": Recorder.pctVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], pth); break; } } else { TextFileOps.Write(pth, tstResult[x, 1].ToString(), Convert.ToInt32(tstResult[x, 2])); } } else { TextFileOps.Write(pth, "<div>", 100); TextFileOps.Write(pth, "Exception Found.............(" + step + ")", 80); TextFileOps.Write(pth, "<br />", 100); TextFileOps.Write(pth, tstResult[x, 1].ToString(), -1); } TextFileOps.Write(pth, "</div>", 100); } tstResult = null; TextFileOps.Write(pth, "<br />", 100); TextFileOps.Write(pth, "</li>", 100); if (tstFail == -1) fnlFail = -1; if (fndExcep == -1) { break; } } break; } case "EX": { //Initialize Firefox and construct the dataArray //the out parameter is the maxColumns in what will be the fnlArray and hence the width of each item in the array xlPath = TestSuite.getXlPath(steName); lstObject = new TestSuite(); lstObject.getTestListing(out lstTest, xlPath); dataArray = tstObj.xlFunctions(tstObj, xlPath, tstName, "Master", out maxCols); //set eleNum (number of elements) to 0 for (int runStep = 0; runStep < dataArray.GetLength(0); runStep++) { eleNum = 0; for (int stpNum = 3; stpNum < dataArray.GetLength(1); stpNum++) { //Get the number of elements in this step data from dataArray if (dataArray[runStep, stpNum] != null) { eleNum++; //increment elenum in the presence of a value } //in dataArray[tstSuite, stpNum] else { break; } } //initialize and set outArray with all data values in the dataArray line item if (eleNum != 0) { outArray = new string[eleNum]; //set outArray to eleNum //set the outarray with all data values or passing to driveFunction for (int setArray = 0; setArray < eleNum; setArray++) { outArray[setArray] = dataArray[runStep, setArray + 3]; } } else { outArray = new string[1]; outArray[0] = ""; } nmFunc = dataArray[runStep, 0]; step = dataArray[runStep, 2]; dbArray = outArray; //call driveFunction to execute the step noted in dataArray[tstSuite. 0] TextFileOps.Write(pth, "<li>", 100); //initialize anm array to hold all of the test results that wiill be written to the results file tstResult = new string[1, 9]; //pass the appropriate vars to the drivefunction tstObj.driveFunction(tstObj, nmFunc, step, dbArray, baseURL, datSource, pth, ref getNeg, ref tstResult, out fndExcep, out tstFail); for (int x = 0; x < tstResult.GetLength(0); x++) { TextFileOps.Write(pth, "<div>", 100); if (fndExcep != -1) { if (tstResult[x, 0] == "verify") switch (tstResult[x, 1].Trim()) { case "button": Recorder.btnVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], pth, getNeg); break; case "dropdown": Recorder.dropdownListVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 5], tstResult[x, 3], pth, getNeg); break; case "field": Recorder.fldVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "grades": Recorder.gradeVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], tstResult[x, 6], tstResult[x, 7], tstResult[x, 8], pth); break; case "image": Recorder.imgVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "link": Recorder.lnkVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "table": Recorder.tblVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], pth, getNeg); break; case "text": case "field text": Recorder.txtVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 5], pth, getNeg); break; case "outcome": Recorder.outcomeVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], tstResult[x, 6], tstResult[x, 7], tstResult[x, 8], pth); break; case "percentage": Recorder.pctVerify(Convert.ToBoolean(tstResult[x, 2]), tstResult[x, 3], tstResult[x, 4], tstResult[x, 5], pth); break; case "weight": Recorder.weightWrite(tstResult[x, 2], tstResult[x, 3], pth); break; } else { TextFileOps.Write(pth, tstResult[x, 1].ToString(), Convert.ToInt32(tstResult[x, 2])); } } else { TextFileOps.Write(pth, "<div>", 100); TextFileOps.Write(pth, "Exception Found.............(" + step + ")", 80); TextFileOps.Write(pth, tstResult[x, 1].ToString(), -1); } TextFileOps.Write(pth, "</div>", 100); } vfyFunc = 0; tstResult = null; TextFileOps.Write(pth, "<br />", 100); //call driveFunction to execute the step noted in dataArray[tstSuite. 0] TextFileOps.Write(pth, "</li>", 100); if (tstFail == -1) fnlFail = -1; if (fndExcep == -1) { break; } } break; } } TextFileOps.Write(pth, "</ul>", 100); switch (radnum) { case 1: { TextFileOps.Write(pth, "<li>", 80); TextFileOps.Write(pth, "Closing Chrome..........\r\n", 80); TextFileOps.Write(pth, "</li>", 80); break; } case 2: TextFileOps.Write(pth, "<li>", 80); TextFileOps.Write(pth, "Closing Internet Explorer..........\r\n", 80); TextFileOps.Write(pth, "</li>", 80); break; { } default: //close Firefox TextFileOps.Write(pth, "<li>", 80); TextFileOps.Write(pth, "Closing Firefox..........\r\n", 80); TextFileOps.Write(pth, "</li>", 80); break; } //exit chromedriver.exe if Chrome is the browser being used if niot here by an exception if (fndExcep != -1) { if (radnum == 1 || radnum == 2) tstObj.Quit(); else tstObj.Close(); } //put a couple newlines in the result file to seperate results for (int a = 0; a < 1; a++) TextFileOps.Write(pth, "\r\n", 0); }
public static ADODB.Connection openConnectionInstance(ref string lDatabase = "") { ADODB.Connection functionReturnValue = default(ADODB.Connection); string Path = null; Scripting.FileSystemObject FSO = new Scripting.FileSystemObject(); if (string.IsNullOrEmpty(lDatabase)) lDatabase = "Pricing.mdb"; if (string.IsNullOrEmpty(serverPath)) setServerPath(); // ERROR: Not supported in C#: OnErrorStatement ADODB.Connection cn = new ADODB.Connection(); //UPGRADE_NOTE: Object openConnectionInstance may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"' functionReturnValue = null; string strDBPath = null; if (string.IsNullOrEmpty(serverPath)) { } else { strDBPath = serverPath + lDatabase; var _with2 = cn; _with2.Provider = "Microsoft.ACE.OLEDB.12.0"; _with2.Properties("Jet OLEDB:System Database").Value = serverPath + "Secured.mdw"; _with2.Open(strDBPath, "liquid", "lqd"); functionReturnValue = cn; } return functionReturnValue; withPass: if (string.IsNullOrEmpty(serverPath)) setNewServerPath(); if (!string.IsNullOrEmpty(serverPath)) { functionReturnValue = null; strDBPath = serverPath + lDatabase; Path = strDBPath + ";Jet " + "OLEDB:Database Password=lqd"; cn.CursorLocation = ADODB.CursorLocationEnum.adUseClient; cn.Open("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;Data Source= " + Path); functionReturnValue = cn; } return functionReturnValue; openConnection_Error: if (Err().Description == "[Microsoft][ODBC Microsoft Access Driver] Not a valid password.") { goto withPass; } else if (Err().Description == "Not a valid password.") { goto withPass; } else { Interaction.MsgBox(Err().Number + " - " + Err().Description); } return functionReturnValue; }
/// <summary> /// Saves TAGs list into database /// </summary> /// <param name="tagsArray">List of TAGs</param> /// <returns>True if success</returns> public bool SaveTags(Tag[] tagsArray) { string strSQL; ADODB.Connection con = new ADODB.Connection(); object obj = new object(); try { con.Open(GenerateConnectionString(), "", "", 0); } catch (Exception) { //TODO: Error logging return false; } for (int i = 0; i < tagsArray.Length; i++) { strSQL = string.Format(NEW_TAG, tagsArray[i].Id, tagsArray[i].Name); try { con.Execute(strSQL, out obj, 0); } catch (Exception) { //TODO: Error logging con.Close(); return false; } } con.Close(); return true; }
/// <summary> /// Saves relations between TAGs and XML rows /// </summary> /// <param name="relationsArray">List with TAG IDs and XML FIELD IDs</param> /// <returns>True if success</returns> public bool SaveRelations(XmlTagRelation[] relationsArray) { string strSQL; ADODB.Connection con = new ADODB.Connection(); object obj = new object(); try { con.Open(GenerateConnectionString(), "", "", 0); } catch (Exception) { //TODO: Error logging return false; } for (int i = 0; i < relationsArray.Length; i++) { strSQL = string.Format(NEW_XML_TAG_RELATION, relationsArray[i].TagID, relationsArray[i].XmlFileID); try { con.Execute(strSQL, out obj, 0); } catch (Exception) { //TODO: Error logging con.Close(); return false; } } con.Close(); return true; }
/// <summary> /// Saves information about XML Files into database /// </summary> /// <param name="filesArray">List with informations about XML Files</param> /// <returns>True if success</returns> public bool SaveFiles(XmlFile[] filesArray) { string strSQL; ADODB.Connection con = new ADODB.Connection(); object obj = new object(); try { con.Open(GenerateConnectionString(), "", "", 0); } catch (Exception) { return false; } for (int i = 0; i < filesArray.Length; i++) { strSQL = string.Format(NEW_XML_FILE, filesArray[i].Id, filesArray[i].Name, filesArray[i].Content, filesArray[i].TimeStamp); try { con.Execute(strSQL, out obj, 0); } catch (Exception) { //TODO: Error logging con.Close(); return false; } } con.Close(); return true; }
private void LoadExtraDataForTable() { try { if(this._array.Count > 0) { ADODB.Connection cnn = new ADODB.Connection(); ADOX.Catalog cat = new ADOX.Catalog(); // Open the Connection cnn.Open(dbRoot.ConnectionString, null, null, 0); cat.ActiveConnection = cnn; ADOX.Columns cols = null; cols = cat.Tables[this.Table.Name].Columns; Column col = this._array[0] as Column; f_TypeName = new DataColumn("TYPE_NAME", typeof(string)); col._row.Table.Columns.Add(f_TypeName); f_AutoKey = new DataColumn("AUTO_INCREMENT", typeof(Boolean)); col._row.Table.Columns.Add(f_AutoKey); f_AutoKeySeed = new DataColumn("AUTO_KEY_SEED", typeof(System.Int32)); col._row.Table.Columns.Add(f_AutoKeySeed); f_AutoKeyIncrement = new DataColumn("AUTO_KEY_INCREMENT", typeof(System.Int32)); col._row.Table.Columns.Add(f_AutoKeyIncrement); int count = this._array.Count; Column c = null; ADOX.Column cx = null; for( int index = 0; index < count; index++) { cx = cols[index]; c = (Column)this[cx.Name]; string hyperlink = "False"; try { hyperlink = cx.Properties["Jet OLEDB:Hyperlink"].Value.ToString(); } catch {} string name = cx.Name; Console.WriteLine("-----------------------------------------"); foreach(ADOX.Property prop in cx.Properties) { Console.WriteLine(prop.Attributes.ToString()); Console.WriteLine(prop.Name); if(null != prop.Value) Console.WriteLine(prop.Value.ToString()); } c._row["TYPE_NAME"] = hyperlink == "False" ? cx.Type.ToString() : "Hyperlink"; try { if(c.Default == "GenGUID()") { c._row["AUTO_INCREMENT"] = Convert.ToBoolean(cx.Properties["Jet OLEDB:AutoGenerate"].Value); } else { c._row["AUTO_INCREMENT"] = Convert.ToBoolean(cx.Properties["Autoincrement"].Value); c._row["AUTO_KEY_SEED"] = Convert.ToInt32(cx.Properties["Seed"].Value); c._row["AUTO_KEY_INCREMENT"] = Convert.ToInt32(cx.Properties["Increment"].Value); } } catch {} } cnn.Close(); } } catch {} }
//保存数据 private void CreateDataTable() { startTime = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + "-" + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString(); ADOX.Catalog catalog = new Catalog(); string tableName = startTime; string myDataPath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "D:\\Data\\" + tableName + ".mdb"; myConnectionString = myDataPath; catalog.Create(myDataPath + ";Jet OLEDB:Engine Type=5"); ADODB.Connection connection = new ADODB.Connection(); connection.Open(myDataPath, null, null, -1); catalog.ActiveConnection = connection; ADOX.Table table = new ADOX.Table(); table.Name = "Data"; ADOX.Column column = new ADOX.Column(); column.ParentCatalog = catalog; column.Name = "Num_My"; column.Type = DataTypeEnum.adInteger; column.DefinedSize = 9; column.Properties["AutoIncrement"].Value = true; table.Columns.Append(column, DataTypeEnum.adInteger, 12); table.Keys.Append("FirstTablePrimaryKey", KeyTypeEnum.adKeyPrimary, column, null, null); table.Columns.Append("Date", DataTypeEnum.adDate, 20); table.Columns.Append("Position", DataTypeEnum.adSingle, 9); catalog.Tables.Append(table); }
public static bool openConnection() { bool functionReturnValue = false; string Path = null; string cnnDBname = null; //this // ERROR: Not supported in C#: OnErrorStatement //If Win7Ver() = True Then //Path = "c:\4posserver\" //Else //Path = String.Empty //End If cnnDBname = "4pos"; cnnDB = new ADODB.Connection(); //cnnDB.Provider = "Microsoft.ACE.OLEDB.12.0" cnnDB.Open(cnnDBname); //win 7 Scripting.FileSystemObject FSO = new Scripting.FileSystemObject(); Scripting.TextStream textstream = default(Scripting.TextStream); string lString = null; if (modWinVer.Win7Ver() == true) { if (FSO.FileExists("C:\\4POS\\4POSWinPath.txt")) { textstream = FSO.OpenTextFile("C:\\4POS\\4POSWinPath.txt", Scripting.IOMode.ForReading, true); lString = textstream.ReadAll; serverPath = lString; //& "pricing.mdb" } else { serverPath = "C:\\4POSServer\\"; //"pricing.mdb" } functionReturnValue = true; return functionReturnValue; } //win 7 serverPath = Strings.Split(Strings.Split(cnnDB.ConnectionString, ";DBQ=")[1], ";")[0]; serverPath = Strings.Split(Strings.LCase(serverPath), "pricing.mdb")[0]; // functionReturnValue = true; return functionReturnValue; if (string.IsNullOrEmpty(serverPath)) setServerPath(); string strDBPath = null; if (string.IsNullOrEmpty(serverPath)) { functionReturnValue = false; } else { functionReturnValue = true; cnnDB = new ADODB.Connection(); strDBPath = serverPath + "Pricing.mdb"; var _with1 = cnnDB; _with1.Provider = "Microsoft.ACE.OLEDB.12.0"; _with1.Properties("Jet OLEDB:System Database").Value = serverPath + "secured.mdw"; _with1.Open(strDBPath, "liquid", "lqd"); } return functionReturnValue; withPass: if (string.IsNullOrEmpty(serverPath)) setNewServerPath(); if (!string.IsNullOrEmpty(serverPath)) { cnnDB = new ADODB.Connection(); strDBPath = serverPath + "pricing.mdb"; Path = strDBPath + ";Jet " + "OLEDB:Database Password=lqd"; cnnDB.CursorLocation = ADODB.CursorLocationEnum.adUseClient; cnnDB.Open("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;Data Source= " + Path); functionReturnValue = true; } return functionReturnValue; openConnection_Error: if (Err().Description == "[Microsoft][ODBC Microsoft Access Driver] Not a valid password.") { goto withPass; } else if (Err().Description == "Not a valid password.") { goto withPass; } functionReturnValue = false; return functionReturnValue; }
public static ADODB.Connection openConnectionShapeInstance() { ADODB.Connection functionReturnValue = default(ADODB.Connection); string Path = null; string lDatabase = null; // ERROR: Not supported in C#: OnErrorStatement ADODB.Connection cn = new ADODB.Connection(); functionReturnValue = null; if (string.IsNullOrEmpty(serverPath)) setServerPath(); string strDBPath = null; if (string.IsNullOrEmpty(serverPath)) { } else { strDBPath = serverPath + "Pricing.mdb"; var _with3 = cn; _with3.Provider = "MSDataShape"; cn.Open("Data Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strDBPath + ";User Id=liquid;Password=lqd;Jet OLEDB:System Database=" + serverPath + "Secured.mdw"); functionReturnValue = cn; } return functionReturnValue; withPass: if (string.IsNullOrEmpty(serverPath)) setNewServerPath(); if (!string.IsNullOrEmpty(serverPath)) { functionReturnValue = null; strDBPath = serverPath + lDatabase; Path = strDBPath + ";Jet " + "OLEDB:Database Password=lqd"; cn.CursorLocation = ADODB.CursorLocationEnum.adUseClient; cn.Open("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;Data Source= " + Path); functionReturnValue = cn; } return functionReturnValue; openConnectionShape_Error: if (Err().Description == "[Microsoft][ODBC Microsoft Access Driver] Not a valid password.") { goto withPass; } else if (Err().Description == "Not a valid password.") { goto withPass; } else { Interaction.MsgBox(Err().Number + " - " + Err().Description); } return functionReturnValue; }
/// <summary> /// Removes all entries from given table /// </summary> /// <param name="table">Table name</param> /// <returns>True if success</returns> public bool DeleteAllData(string table) { string strSQL = string.Format(DELETE_ALL, table); ADODB.Connection con = new ADODB.Connection(); object obj = new object(); try { con.Open(GenerateConnectionString(), "", "", 0); } catch (Exception) { //TODO: Error logging return false; } try { con.Execute(strSQL, out obj, 0); } catch (Exception) { //TODO: Error logging con.Close(); return false; } con.Close(); return true; }
private void btnOK_Click(object sender, EventArgs e) { ADODB.Connection objCon; DialogResult update; string[,] argArray; object[,] idxUpdate; object[] rtnList; object[] exTest; int numTests; string tstList; string argID; string itmList; string msgString; string tstID; string strCon; string strSQL; objCon = new ADODB.Connection(); itmList = ""; tstList = ""; strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" + "database=functional_test_data;option=3"; //get the number of checkboxes that are checked from dbUpdater form idxUpdate = chkBoxNumChecked(chkArgument); for (int j = 0; j < idxUpdate.GetLength(0); j++) itmList = itmList + idxUpdate[j, 0] + "\t" + idxUpdate[j, 1] + "\r\n"; //dimension an array for the arguments will be going into the database argArray = new string[idxUpdate.GetLength(0), 2]; for (int z = 0; z < argArray.GetLength(0); z++) { argArray[z, 0] = idxUpdate[z, 0].ToString(); argArray[z, 1] = lblArgument[Convert.ToInt32(idxUpdate[z, 0])].Text; } //get the test ID strSQL = "SELECT id FROM test WHERE name = '" + tstname + "'"; rtnList = db_access(strSQL); tstID = rtnList[0].ToString(); //get the argument set id strSQL = "SELECT argument_set_id FROM step WHERE (test_id = '" + tstID + "' AND number = " + thsStep[0] + ")"; rtnList = db_access(strSQL); argID = rtnList[0].ToString(); strSQL = "SELECT COUNT(*) FROM step WHERE argument_set_id = '" + argID + "'"; rtnList = db_access(strSQL); numTests = Convert.ToInt32(rtnList[0]); if (numTests <= 1) { if (numTests != 0) { //get the argument set id strSQL = "SELECT test_id FROM step WHERE argument_set_id = '" + argID + "'"; rtnList = db_access(strSQL); } } else { strSQL = "SELECT test_id FROM step WHERE (argument_set_id = '" + argID + "' AND test_id <> (SELECT id FROM test WHERE name = '" + tstname + "'))"; rtnList = db_access(strSQL); } if (rtnList.Length != 0) { for (int k = 0; k < rtnList.Length; k++) { strSQL = "SELECT name from test WHERE id = '" + rtnList[k] + "'"; exTest = db_access(strSQL); tstList = tstList + exTest[0] + "\r\n"; } msgString = "You will be updating Step " + thsStep[0] + " of the " + tstname + " test.\r\nThe following data items will be updated\r\n\r\nIndex#\tData Item\r\n" + itmList + "\r\nYou will not be able to undo these changes once they are done. " + "The argument set that you are updating is also used in the following tests:\r\n\r\n" + tstList + "\r\nAre you sure you want to Continue?\r\n\r\nPress 'Yes' to Update. Press 'No' to exit"; } else { msgString = "You will be updating Step " + thsStep[0] + " of the " + tstname + " test.\r\nThe following data items will be updated\r\n\r\nIndex#\tData Item\r\n" + itmList + "\r\nYou will not be able to undo these changes once they are done. " + "The argument set that you are updating is not used in any other tests>" + "\r\nAre you sure you want to Continue?\r\n\r\nPress 'Yes' to Update. Press 'No' to exit"; } update = MessageBox.Show(msgString, "Database Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (update == DialogResult.Yes) { objCon.Open(strCon); for (int x = 0; x < argArray.GetLength(0); x++) { strSQL = "UPDATE argument SET value='" + argArray[x, 1] + "' WHERE argument_set_id = '" + argID + "' AND seq = " + (Convert.ToInt32(argArray[x, 0]) + 1).ToString(); objCon.Execute(strSQL, out missing, 0); } objCon.Close(); MessageBox.Show("Database rows updated.\r\nDone! ", "Database Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
public void TestFillDataTableByNameWithADODBRecordSet() { OleDbDataAdapter adapter = new OleDbDataAdapter(); DataSet stuDS = new DataSet(); DataTable stuTable = new DataTable("student"); stuTable.Columns.Add("id", typeof(int)); stuTable.Columns.Add("name", typeof(string)); stuDS.Tables.Add(stuTable); //Use ADO objects from ADO library (msado15.dll) imported // as.NET library ADODB.dll using TlbImp.exe ADODB.Connection adoConn = new ADODB.Connection(); ADODB.Recordset adoRS = new ADODB.Recordset(); adoConn.Open("Provider=CUBRIDProvider;Location=test-db-server;Data Source=demodb;User Id=dba;Port=30000", "", "", -1); adoRS.Open("SELECT * FROM student", adoConn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, 1); int fillRowCount = adapter.Fill(stuDS, adoRS, "student"); //This method implicitly calls Close on the ADO object when the fill operation is complete. //adoRS.Close(); adoConn.Close(); Assert.AreEqual(3, fillRowCount); Assert.AreEqual(3, stuTable.Rows.Count); }
public static bool openConnectionReport() { bool functionReturnValue = false; string Path = null; // ERROR: Not supported in C#: OnErrorStatement bool createDayend = false; string strDBPath = null; Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); createDayend = false; functionReturnValue = true; cnnDBreport = new ADODB.Connection(); strDBPath = modRecordSet.serverPath + "report" + My.MyProject.Forms.frmMenu.lblUser.Tag + ".mdb"; var _with1 = cnnDBreport; _with1.Provider = "Microsoft.ACE.OLEDB.12.0"; _with1.Properties("Jet OLEDB:System Database").Value = modRecordSet.serverPath + "Secured.mdw"; _with1.Open(strDBPath, "liquid", "lqd"); return functionReturnValue; withPass: //If serverPath = "" Then setNewServerPath //If serverPath <> "" Then cnnDBreport = new ADODB.Connection(); strDBPath = modRecordSet.serverPath + "report" + My.MyProject.Forms.frmMenu.lblUser.Tag + ".mdb"; //UPGRADE_WARNING: Couldn't resolve default property of object Path. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' Path = strDBPath + ";Jet " + "OLEDB:Database Password=lqd"; cnnDBreport.CursorLocation = ADODB.CursorLocationEnum.adUseClient; //UPGRADE_WARNING: Couldn't resolve default property of object Path. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' cnnDBreport.Open("Provider=Microsoft.ACE.OLEDB.12.0;Persist Security Info=False;Data Source= " + Path); functionReturnValue = true; return functionReturnValue; openConnection_Error: //End If if (Err().Description == "[Microsoft][ODBC Microsoft Access Driver] Not a valid password.") { goto withPass; } else if (Err().Description == "Not a valid password.") { goto withPass; } functionReturnValue = false; Interaction.MsgBox(Err().Number + " " + Err().Description + " " + Err().Source + Constants.vbCrLf + Constants.vbCrLf + " openConnectionReport object has not been made."); return functionReturnValue; }
public void TestRefreshDataTableWithADODBRecordSet_Schema() { OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; DataSet stuDS = new DataSet(); DataTable stuTable = new DataTable("student"); stuDS.Tables.Add(stuTable); //Use ADO objects from ADO library (msado15.dll) imported // as.NET library ADODB.dll using TlbImp.exe ADODB.Connection adoConn = new ADODB.Connection(); ADODB.Recordset adoRS = new ADODB.Recordset(); adoConn.Open("Provider=CUBRIDProvider;Location=test-db-server;Data Source=demodb;User Id=dba;Port=30000", "", "", -1); adoRS.Open("SELECT * FROM student", adoConn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, 1); adapter.Fill(stuTable, adoRS); adoRS.Requery(0); int refreshRowCount = adapter.Fill(stuTable, adoRS); // This method does not call Close on the ADO object when the fill operation is complete. adoRS.Close(); adoConn.Close(); Assert.IsNotNull(stuTable.PrimaryKey); Assert.AreEqual(3, refreshRowCount); }
private void LoadExtraDataForView() { try { if(this._array.Count > 0) { ADODB.Connection cnn = new ADODB.Connection(); ADODB.Recordset rs = new ADODB.Recordset(); ADOX.Catalog cat = new ADOX.Catalog(); // Open the Connection cnn.Open(dbRoot.ConnectionString, null, null, 0); cat.ActiveConnection = cnn; rs.Source = cat.Views[this.View.Name].Command; rs.Fields.Refresh(); ADODB.Fields flds = rs.Fields; Column col = this._array[0] as Column; f_TypeName = new DataColumn("TYPE_NAME", typeof(string)); col._row.Table.Columns.Add(f_TypeName); f_AutoKey = new DataColumn("AUTO_INCREMENT", typeof(Boolean)); col._row.Table.Columns.Add(f_AutoKey); Column c = null; ADODB.Field fld = null; int count = this._array.Count; for( int index = 0; index < count; index++) { fld = flds[index]; c = (Column)this[fld.Name]; c._row["TYPE_NAME"] = fld.Type.ToString(); c._row["AUTO_INCREMENT"] = false; } rs.Close(); cnn.Close(); } } catch {} }
override internal void LoadAll() { DataTable metaData = CreateDataTable(); ADODB.Connection cnn = new ADODB.Connection(); ADOX.Catalog cat = new ADOX.Catalog(); // Open the Connection cnn.Open(dbRoot.ConnectionString, null, null, 0); cat.ActiveConnection = cnn; ADOX.Procedure proc = cat.Procedures[this.Procedure.Name]; ADODB.Command cmd = proc.Command as ADODB.Command; // Retrieve Parameter information cmd.Parameters.Refresh(); if(cmd.Parameters.Count > 0) { int ordinal = 0; foreach(ADODB.Parameter param in cmd.Parameters) { DataRow row = metaData.NewRow(); string hyperlink = "False"; try { hyperlink = param.Properties["Jet OLEDB:Hyperlink"].Value.ToString(); } catch {} row["TYPE_NAME"] = hyperlink == "False" ? param.Type.ToString() : "Hyperlink"; row["PROCEDURE_CATALOG"] = this.Procedure.Database; row["PROCEDURE_SCHEMA"] = null; row["PROCEDURE_NAME"] = this.Procedure.Name; row["PARAMETER_NAME"] = param.Name; row["ORDINAL_POSITION"] = ordinal++; row["PARAMETER_TYPE"] = param.Type;//.ToString(); row["PARAMETER_HASDEFAULT"] = false; row["PARAMETER_DEFAULT"] = null; row["IS_NULLABLE"] = false; row["DATA_TYPE"] = param.Type;//.ToString(); row["CHARACTER_MAXIMUM_LENGTH"] = 0; row["CHARACTER_OCTET_LENGTH"] = 0; row["NUMERIC_PRECISION"] = param.Precision; row["NUMERIC_SCALE"] = param.NumericScale; row["DESCRIPTION"] = ""; // row["TYPE_NAME"] = ""; row["LOCAL_TYPE_NAME"] = ""; metaData.Rows.Add(row); } } cnn.Close(); base.PopulateArray(metaData); }