当前位置: 首页>>代码示例>>C#>>正文


C# System.Data.OleDb.OleDbCommand.Dispose方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbCommand.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.Data.OleDb.OleDbCommand.Dispose方法的具体用法?C# System.Data.OleDb.OleDbCommand.Dispose怎么用?C# System.Data.OleDb.OleDbCommand.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbCommand的用法示例。


在下文中一共展示了System.Data.OleDb.OleDbCommand.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: button3_Click

        private void button3_Click(object sender, EventArgs e)
        {   // Botão btnResultados
            try
            {
                string id1 = txtIdade1.Text;
                string id2 = txtIdade2.Text;
                string strSsexo = "";
                if (rbMasculino.Checked) strSsexo = " sexo = 'M' AND ";
                    else if (rbFeminino.Checked) strSsexo = " sexo = 'F' AND ";
                        else strSsexo = "";

                sql = "select * from alunos WHERE " + strSsexo 
                    + " idade>=" + id1 + " AND idade<=" + id2 
                    + " ORDER BY nome";
                stm = new System.Data.OleDb.OleDbCommand(sql, conexao);
                rs = stm.ExecuteReader();
                string strSaida = "";
                while (rs.Read())
                {
                    string dados = "RGM: " + rs.GetString(0) 
                        + ", " + rs.GetString(1) + ", idade: " + rs.GetInt32(3)
                        + ", sexo: " + rs.GetString(4)
                        + ", curso: " + rs.GetString(2);
                    strSaida += dados + "\r\n";
                }
                txtResultados.Text = strSaida;
            }
            catch (Exception exsql) { MessageBox.Show("Erro na consulta"); }
            if(stm!=null)stm.Dispose();
            if(rs!=null)rs.Close();
        }
开发者ID:rodrigogregorioneri,项目名称:Projetos-e-exercicios-faculdade,代码行数:31,代码来源:Form2.cs

示例2: AnalyzeExcel

        public static bool AnalyzeExcel(ExcelXMLLayout layout)
        {
            System.Data.OleDb.OleDbConnection conn = null;
            try
            {
                conn = new System.Data.OleDb.OleDbConnection(MakeConnectionString(layout.solution.path));

                conn.Open();
                System.Data.DataTable table = conn.GetOleDbSchemaTable(
                    System.Data.OleDb.OleDbSchemaGuid.Columns,
                    new object[] { null, null, layout.sheet + "$", null });

                layout.Clear();
                System.Diagnostics.Debug.WriteLine("Start Analyze [" + table.Rows.Count + "]");

                foreach (System.Data.DataRow row in table.Rows)
                {
                    string name = row["Column_Name"].ToString();

                    System.Diagnostics.Debug.WriteLine(name);

                    // 测试数据类型
                    ExcelXMLLayout.KeyType testType = ExcelXMLLayout.KeyType.Unknown;
                    {
                        System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(
                            string.Format("select [{0}] from [{1}$]", name, layout.sheet), conn
                            );
                        System.Data.OleDb.OleDbDataReader r = cmd.ExecuteReader();
                        while (r.Read())
                        {
                            System.Diagnostics.Debug.WriteLine(r[0].GetType());
                            if (r[0].GetType() == typeof(System.Double))
                            {
                                testType = ExcelXMLLayout.KeyType.Integer;
                                break;
                            }
                            if (testType == ExcelXMLLayout.KeyType.String)
                            {
                                break;
                            }
                            testType = ExcelXMLLayout.KeyType.String;
                        }
                        r.Close();
                        cmd.Dispose();
                    }

                    layout.Add(name, testType);
                }
                table.Dispose();
                conn.Close();

                return true;
            }
            catch (Exception outErr)
            {
                lastError = string.Format("无法分析,Excel 无法打开\r\n{0}", outErr.Message);
            }
            return false;
        }
开发者ID:ialex32x,项目名称:iExcelExport,代码行数:59,代码来源:ExcelFile.cs

示例3: btnGo_Click

        protected void btnGo_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            string sql = "";
            System.Data.DataSet ds = new System.Data.DataSet();
            System.Data.OleDb.OleDbDataReader dr;
            System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();
            //http://www.c-sharpcorner.com/UploadFile/dchoksi/transaction02132007020042AM/transaction.aspx
            //get this from connectionstrings.com/access
            conn.ConnectionString = txtConnString.Text;
            conn.Open();
            //here I can talk to my db...
            System.Data.OleDb.OleDbTransaction Trans;
            Trans = conn.BeginTransaction(System.Data.IsolationLevel.Chaos);

            try
            {

                comm.Connection = conn;
                comm.Transaction = Trans;
               // Trans.Begin();

                //Console.WriteLine(conn.State);
                sql = txtSQL.Text;
                comm.CommandText = sql;
                if (sql.ToLower().IndexOf("select") == 0)
                {
                    dr = comm.ExecuteReader();
                    while (dr.Read())
                    {
                        txtresults.Text = dr.GetValue(0).ToString();
                    }
                }
                else
                {
                    txtresults.Text = comm.ExecuteNonQuery().ToString();
                }
                Trans.Commit();
            }
            catch (Exception ex)
            {
                txtresults.Text = ex.Message;
                Trans.Rollback();
            }
            finally
            {

                comm.Dispose();
                conn.Close();
                conn = null;
            }
        }
开发者ID:jasonhuber,项目名称:2010Fall_CIS407,代码行数:52,代码来源:Default.aspx.cs

示例4: Main

        static void Main(string[] args)
        {
            string connstring =
            @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DropBox\My Dropbox\Devry\CIS407\SU10B\day5\NorthWind.mdb;";
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            string sql = "";
            System.Data.DataSet ds = new System.Data.DataSet();
            System.Data.OleDb.OleDbDataReader dr;
            System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();

            try
            {
                //get this from connectionstrings.com/access
                conn.ConnectionString = connstring;
                conn.Open();
                //here I can talk to my db...
                comm.Connection = conn;

                //Console.WriteLine(conn.State);
                sql = Console.ReadLine();
                comm.CommandText = sql;
                if (sql.ToLower().IndexOf("select") == 0)
                {
                    dr = comm.ExecuteReader();
                    while (dr.Read())
                    {
                        Console.WriteLine(dr.GetString(0));
                    }
                }
                else
                {
                    Console.WriteLine(comm.ExecuteNonQuery().ToString());
                }
            }
            catch ( Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.Read();
            }
            finally
            {
                Console.ReadLine();
                comm.Dispose();
                conn.Close();
                conn = null;
            }
        }
开发者ID:jasonhuber,项目名称:2010Fall_CIS407,代码行数:47,代码来源:Program.cs

示例5: btnGo_Click

        protected void btnGo_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            string sql = "";
            System.Data.DataSet ds = new System.Data.DataSet();
            System.Data.OleDb.OleDbDataReader dr;
            System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();

            try
            {
                //get this from connectionstrings.com/access
                conn.ConnectionString = txtConnString.Text;
                conn.Open();
                //here I can talk to my db...
                comm.Connection = conn;

                //Console.WriteLine(conn.State);
                sql = txtSQL.Text;
                comm.CommandText = sql;
                if (sql.ToLower().IndexOf("select") == 0)
                {
                    dr = comm.ExecuteReader();
                    while (dr.Read())
                    {
                        txtresults.Text = dr.GetValue(0).ToString();
                    }
                }
                else
                {
                    txtresults.Text = comm.ExecuteNonQuery().ToString();
                }
            }
            catch (Exception ex)
            {
                txtresults.Text = ex.Message;

            }
            finally
            {

                comm.Dispose();
                conn.Close();
                conn = null;
            }
        }
开发者ID:jasonhuber,项目名称:2010Fall_CIS407,代码行数:45,代码来源:Default.aspx.cs

示例6: isHomologyNote

 public int isHomologyNote(string Table, string term1, string term2, string Value1, string Value2)
 {
     string tem_sql = "";//定义字符串变量
     System.Data.OleDb.OleDbConnection tem_conn =
         new System.Data.OleDb.OleDbConnection(connstr);//连接数据库
     System.Data.OleDb.OleDbCommand tem_comm;//定义OleDbCommand类
     tem_conn.Open();//打开数据库的连接
     //设置SQL语句,查找要添加的记录
     tem_sql = "select top 1 * From " + Table + " where " + term1 + " = '" + 
         Value1 + "' and " + term2 + " = '" + Value2 + "'";
     tem_comm = new System.Data.OleDb.OleDbCommand(tem_sql, tem_conn);//执行SQL语句
     int RecordCount = 0;//定义变量
     if (tem_comm.ExecuteScalar() == null)//如果查询为空
         RecordCount = 0;
     else
         RecordCount = (int)tem_comm.ExecuteScalar();//返回查找结果的个数
     tem_conn.Close();//关闭连接
     tem_comm.Dispose();//释放资源
     tem_conn.Dispose();//释放资源
     return RecordCount;//返回查询记录数量
 }
开发者ID:mahuidong,项目名称:c-1200-II,代码行数:21,代码来源:Frm_Main.cs

示例7: SaveAs

 public bool SaveAs(string fileName, System.Data.DataTable dataTable)
 {
     if (dataTable == null || dataTable.Rows.Count == 0) return false;
     if (xlApp == null) return false;
     _workbook = xlApp.Workbooks.Add(Type.Missing);
     _worksheet = (Worksheet)_workbook.Worksheets[1];
     for (var i = 0; i < dataTable.Columns.Count; i++)
     {
         _worksheet.Cells[1, i + 1] = dataTable.Columns[i].ColumnName;
         //range = (Range)worksheet.Cells[1, i + 1];
         //range.Interior.ColorIndex = 15;
         //range.Font.Bold = true;
     }
     _workbook.SaveAs(fileName,XlFileFormat.xlWorkbookNormal, "", "", false, false, XlSaveAsAccessMode.xlExclusive,XlPlatform.xlWindows, false, false, false, false);
     _workbook.Close(true, fileName, false);
     xlApp.Quit();
     _connectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + fileName + "';Extended Properties=Excel 8.0;"; // строка подключения
     using (var excelConn = new System.Data.OleDb.OleDbConnection(_connectionString)) // используем OleDb
     {
         var queryValues = String.Empty;
         excelConn.Open();
         for (var i = 0; i < dataTable.Rows.Count; i++)
         {
             for (var c = 0; c < dataTable.Columns.Count; c++)
             {
                 queryValues += dataTable.Rows[i][c] + "','";
             }
             queryValues = queryValues.Substring(0, queryValues.Length - 3);
             var writeCmd = new System.Data.OleDb.OleDbCommand("INSERT INTO [Лист1$] VALUES ('" + queryValues + "')", excelConn);
             writeCmd.ExecuteNonQuery(); // вставляем данные в лист1 файла - filename
             writeCmd.Dispose();
             queryValues = String.Empty;
         }
         excelConn.Close();
     }
     return System.IO.File.Exists(fileName);
 }
开发者ID:pulse-computer-consulting,项目名称:NucleusPub,代码行数:37,代码来源:Excel.cs

示例8: ToDataSet

        /// <summary>
        /// 将当前连接的 Excel 文件中指定的 sheets 导出到 <see cref="DataSet"/> 中。
        /// </summary>
        /// <param name="sheetNames">需要导出的 Sheet 名字集。默认 Sheet1 </param>
        /// <exception cref="System.Data.OleDb.OleDbException">一般性数据库错误,或者指定的 Sheet 名字不存在对应的数据。</exception>
        /// <returns></returns>
        public DataSet ToDataSet(params string[] sheetNames)
        {
            if (sheetNames == null || sheetNames.Length == 0)
                sheetNames = new string[] { "sheet1" };
            string ConnStr = ConnectionString;
            //Conn 
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(ConnStr);

            //new DataSet 
            DataSet myDataSet = new DataSet();
            //Command
            System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();

            cmd.Connection = conn;
            try
            {
                foreach (var p in sheetNames)
                {
                    cmd.CommandText = string.Format(selectSqlString, p);
                    DataTable dt = new DataTable(p);
                    conn.Open();
                    dt.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection));
                    myDataSet.Tables.Add(dt);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
            }
            return myDataSet;
        }
开发者ID:RukaiYu,项目名称:EnterpriseDevelopmentFx,代码行数:42,代码来源:ExcelManager.cs

示例9: ExecuteQuery

        /// <summary>
        /// Run a transact SQL query against the database.
        /// </summary>
        /// <param name="sqlQuery">String with the SQL query (Insert, Update, Delete, etc).</param>
        /// <returns>The number of rows affected or -1 if an exception occurs.</returns>
        public int ExecuteQuery(string sqlQuery)
        {
            // Do not proceed if the database is not connected.
            if (this.IsConnected == false)
            {
                this.hasException = true;
                this.lastException = new System.Exception("You cannot query a database until you connect to it (ExecuteQuery(string). Connect first.");
                if (this.ThrowExceptions == true) throw this.lastException;
                return -1;
            }

            // Clear past exceptions
            this.hasException = false;

            /*
             * Switch to the appropriate database client and execute the query
             *
             * Set the default output to -1 (which means that there was an error)
             * Create a Command object
             * Set the Command to use the current database's object
             * Set the Command's timeout value (if exceeded, an exception will occur)
             * Execute the SQL query, populating the output with the number of rows affected
             * Dispose of the Command object
             */

            int output = -1;

            switch (this.DataClient)
            {
                case DatabaseClient.OleClient:

                    try
                    {
                        System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();
                        cmd.Connection = this.oleConn;
                        cmd.CommandText = sqlQuery;
                        cmd.CommandTimeout = this.CommandTimeout;
                        output = cmd.ExecuteNonQuery();
                        cmd.Dispose();
                    }
                    catch (Exception exception)
                    {
                        hasException = true;
                        lastException = exception;

                        if (ThrowExceptions == true)
                            throw lastException;
                    }

                    break;

                case DatabaseClient.SqlClient:

                    try
                    {
                        System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                        cmd.Connection = this.sqlConn;
                        cmd.CommandText = sqlQuery;
                        cmd.CommandTimeout = this.CommandTimeout;
                        output = cmd.ExecuteNonQuery();
                        cmd.Dispose();
                    }
                    catch (Exception exception)
                    {
                        hasException = true;
                        lastException = exception;

                        if (ThrowExceptions == true) throw lastException;
                    }

                    break;

                default:
                    this.isConnected = false;
                    this.hasException = true;
                    this.lastException = new SystemException("The database client type entered is invalid (DataClient=" + this.DataClient.ToString() + ").");

                    if (this.ThrowExceptions == true)
                        throw this.lastException;

                    break;
            }

            return output;
        }
开发者ID:SimWitty,项目名称:SimWitty,代码行数:90,代码来源:Database.cs

示例10: GetResultWeaponClassesWithResults

		internal Structs.ResultWeaponsClass[] GetResultWeaponClassesWithResults()
		{
			string select = "SELECT DISTINCT weapons.class " +
				"FROM (weapons RIGHT JOIN Competitors ON weapons.WeaponId = Competitors.WeaponId) " +
				"INNER JOIN CompetitorResults ON Competitors.CompetitorId = CompetitorResults.CompetitorId;";

			System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(
				select, myInterface.databaseClass.Conn);
			
			if (myInterface.databaseClass.Conn.State != ConnectionState.Open)
				myInterface.databaseClass.Conn.Open();

			System.Data.OleDb.OleDbDataReader r = cmd.ExecuteReader();

			List<Structs.WeaponClass> wclasses = new List<Structs.WeaponClass>();

			while (r.Read())
			{
				wclasses.Add((Structs.WeaponClass)r.GetInt32(0));
			}

			
			r.Dispose();
			cmd.Dispose();

			List<Structs.ResultWeaponsClass> rwclasses = new List<Structs.ResultWeaponsClass>();

			foreach (Structs.WeaponClass wclass in wclasses)
			{
				// Check for duplicates
				Structs.ResultWeaponsClass rwc=
					CConvert.ConvertWeaponsClassToResultClass(
						wclass, 
						myInterface.CompetitionCurrent.Type);
				if (!rwclasses.Contains(rwc))
					rwclasses.Add(rwc);
			}

			// Sort
			rwclasses.Sort();

			return rwclasses.ToArray();
		}
开发者ID:WinShooter,项目名称:WinShooter-Legacy,代码行数:43,代码来源:CResult.cs

示例11: InsertData

        /// <summary>
        /// InsertData
        /// </summary>
        /// <param name="fileName">模板文件在服务器端的完全路径</param>
        /// <param name="theData"></param>
        private bool InsertData(string fileName, DataTable theData)
        {
            // connection use oledb
            DataTable dt = theData;
            string strConn = string.Format(CONNECTION_STRING_WRITE, fileName);
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(strConn);
            System.Data.OleDb.OleDbCommand cmd = null;
            bool bRet = false;
            try
            {
                conn.Open();
                //cmd = new System.Data.OleDb.OleDbCommand("Create table [sheet1]([name] Text, [age] int, [phone] Text)", conn);
                //cmd.ExecuteNonQuery();
                string strSQL = InsertSQL;
                cmd = new System.Data.OleDb.OleDbCommand(strSQL, conn);
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    cmd.Parameters.Add(i.ToString(), System.Data.OleDb.OleDbType.VarChar);
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        cmd.Parameters[j.ToString()].Value = dt.Rows[i][j].ToString();
                    }
                    cmd.ExecuteNonQuery();
                }
                bRet = true;
            }
            catch (Exception e2)
            {
                bRet = false;
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                conn.Dispose();
            }

            return bRet;
        }
开发者ID:XiaoQiJun,项目名称:BPS,代码行数:50,代码来源:ExcelTemplate.cs

示例12: DoExport

        public static bool DoExport(ExcelXMLLayout layout)
        {
            try
            {
                System.Data.OleDb.OleDbConnection conn =
                    new System.Data.OleDb.OleDbConnection(DB.ExcelFile.MakeConnectionString(layout.solution.path));

                StringBuilder sb = new StringBuilder(1024 * 1024);
                try
                {
                    conn.Open();
                    System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(
                        DB.ExcelFile.MakeSelectString(layout), conn);

                    try
                    {
                        System.Data.OleDb.OleDbDataReader r = cmd.ExecuteReader();
                        sb.Append("<?xml version='1.0' encoding='utf-8'?>");
                        sb.Append("<dataroot>");
                        while (r.Read())
                        {
                            if (IsHeadRow(r, layout))
                            {
                                continue;
                            }
                            sb.AppendFormat("<{0}>", layout.name);
                            for (int i = 0; i < r.FieldCount; ++i)
                            {
                                if (layout.typed)
                                {
                                    sb.AppendFormat("<{0} type='{1}'>{2}</{0}>",
                                        layout[i].name, ExcelXMLLayout.Type2Int(layout[i].type), r[i].ToString());
                                }
                                else
                                {
                                    sb.AppendFormat("<{0}>{1}</{0}>", layout[i].name, r[i].ToString());
                                }
                            }
                            sb.AppendFormat("</{0}>", layout.name);
                        }
                        sb.Append("</dataroot>");
                        r.Dispose();
                    }
                    catch (Exception rErr)
                    {
                        lastError = string.Format("表格查询命令\r\n{0}", rErr.ToString());
                        cmd.Dispose();
                        conn.Close();
                        conn.Dispose();
                        return false;
                    }
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
                catch (Exception connOpenErr)
                {
                    lastError = string.Format("表格打开失败\r\n{0}", connOpenErr.ToString());
                    conn.Dispose();
                    return false;
                }
                //System.Diagnostics.Debug.WriteLine(sb.ToString());

                try
                {
                    System.IO.TextWriter w = System.IO.File.CreateText(layout.path);
                    w.Write(sb.ToString());
                    w.Close();
                }
                catch (Exception wErr)
                {
                    lastError = string.Format("目标XML文件无法写入\r\n{0}", wErr.ToString());
                    return false;
                }

                return true;
            }
            catch (Exception outErr)
            {
                lastError = string.Format("Excel 无法打开\r\n{0}", outErr.ToString());
                System.Diagnostics.Debug.WriteLine(outErr.ToString());
            }
            return false;
        }
开发者ID:ialex32x,项目名称:iExcelExport,代码行数:84,代码来源:ExcelFile.cs

示例13: makeAll

        /// <summary> <p>Creates skeletal source code (without correct data structure but no business
        /// logic) for all segments found in the normative database.  </p>
        /// </summary>
        public static void makeAll(System.String baseDirectory, System.String version)
        {
            //make base directory
            if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
            {
                baseDirectory = baseDirectory + "/";
            }
            System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Segment");

            //get list of data types
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            System.String sql = "SELECT seg_code, [section] from HL7Segments, HL7Versions where HL7Segments.version_id = HL7Versions.version_id AND hl7_version = '" + version + "'";
            System.Data.OleDb.OleDbCommand temp_OleDbCommand = new System.Data.OleDb.OleDbCommand();
            temp_OleDbCommand.Connection = conn;
            temp_OleDbCommand.CommandText = sql;
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList segments = new System.Collections.ArrayList();
            while (rs.Read())
            {
                System.String segName = System.Convert.ToString(rs[1 - 1]);
                if (System.Char.IsLetter(segName[0]))
                    segments.Add(altSegName(segName));
            }
            temp_OleDbCommand.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            if (segments.Count == 0)
            {
                log.Warn("No version " + version + " segments found in database " + conn.Database);
            }

            for (int i = 0; i < segments.Count; i++)
            {
                try
                {
                    System.String seg = (System.String)segments[i];
                    System.String source = makeSegment(seg, version);
                    using (System.IO.StreamWriter w = new System.IO.StreamWriter(targetDir.ToString() + @"\" + GetSpecialFilename(seg) + ".cs"))
                    {
                        w.Write(source);
                        w.Write("}");
                    }
                }
                catch (System.Exception e)
                {
                    System.Console.Error.WriteLine("Error creating source code for all segments: " + e.Message);
                    SupportClass.WriteStackTrace(e, Console.Error);
                }
            }
        }
开发者ID:snosrap,项目名称:nhapi,代码行数:54,代码来源:SegmentGenerator.cs

示例14: PrepareDatabase


//.........这里部分代码省略.........
                        "VALUES ('" + NewDescription +
                        "', '" + R.CreatedDate +
                        "', 9" +
                        ", '" + R.DisplayName +
                        "', 15" +
                        "," + SessionID +
                        "," + Convert.ToInt32(R.IsDesktopCapture) +
                        "," + Convert.ToInt32(R.IsPrimaryCamera) +
                        "," + R.SizeOnDisk +
                        "," + R.PlayLength +
                        "," + Convert.ToInt32(R.HasAudio) +
                        "," + Convert.ToInt32(R.HasVideo) +
             						")";

                    try
                    {
                        CM.CommandText = sSQL;
                        CM.ExecuteNonQuery();
                    }
                    catch(System.Data.OleDb.OleDbException Err)
                    {
                        MessageBox.Show(Err.Message);
                        string peek = Err.Message;
                        return;
                    }
                    catch(Exception Err)
                    {
                        MessageBox.Show(Err.Message);
                        string sPeek = Err.Message;
                        return;
                    }
                }

                foreach(OCL.Note N in RS.AllVisibleNotes(frmParent.LUser))
                {
                    int NoteID = 0;
                    sSQL = "INSERT INTO tblNotes(SyncTime,Description,SessionId,Created) VALUES('" +
                        N.SyncTime + "','" + N.Description + "'," + SessionID + ",'" +
                        N.Created +"'" +
                        ")";
                    CM.CommandText = sSQL;
                    try
                    {
                        CM.CommandText = sSQL;
                        CM.ExecuteNonQuery();
                        CM.CommandText = "SELECT @@IDENTITY";
                        NoteID = (int)CM.ExecuteScalar();

                    }
                    catch(System.Data.OleDb.OleDbException Err)
                    {
                        MessageBox.Show(Err.Message);
                        string peek = Err.Message;
                        return;
                    }
                    catch(Exception Err)
                    {
                        MessageBox.Show(Err.Message);
                        string sPeek = Err.Message;
                        return;
                    }
                    OCL.Attachments FileAttachments = N.AllVisibleAttachments(frmParent.LUser);
                    foreach(OCL.Attachment A in FileAttachments)
                    {
                        sSQL = "INSERT INTO tblAttachments(OriginalName,StoredName,NoteId,Created,FileSize) VALUES(" +
                            " '" + A.OriginalName + "','" + A.StoredName +
                            "'," + NoteID.ToString() +
                            ",'" + A.Created + "'" +
                            "," + A.FileSize +
                            ")";
                        CM.CommandText = sSQL;
                        try
                        {

                            CM.ExecuteNonQuery();
                        }
                        catch(System.Data.OleDb.OleDbException Err)
                        {
                            MessageBox.Show(Err.Message);
                            string peek = Err.Message;
                            return;
                        }
                        catch(Exception Err)
                        {
                            MessageBox.Show(Err.Message);
                            string sPeek = Err.Message;
                            return;
                        }
                    }
                }
            }
            DA.Dispose();
            DT.Dispose();
            CM.Dispose();
            #endregion

            AC.Close();
            AC.Dispose();
            System.Threading.Thread.SpinWait(500000);
        }
开发者ID:CarverLab,项目名称:Oyster,代码行数:101,代码来源:frmHardDisc.cs

示例15: makeAll

        /// <summary> <p>Creates skeletal source code (without correct data structure but no business
        /// logic) for all segments found in the normative database.  </p>
        /// </summary>
        public static void makeAll(System.String baseDirectory, System.String version)
        {
            //make base directory
            if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
            {
                baseDirectory = baseDirectory + "/";
            }
            System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "segment");

            //get list of data types
            //UPGRADE_NOTE: There are other database providers or managers under System.Data namespace which can be used optionally to better fit the application requirements. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1208'"
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;

            //UPGRADE_TODO: Method 'java.sql.Connection.createStatement' was converted to 'SupportClass.TransactionManager.manager.CreateStatement' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlConnectioncreateStatement'"
            System.String sql = "SELECT seg_code, [section] from HL7Segments, HL7Versions where HL7Segments.version_id = HL7Versions.version_id AND hl7_version = '" + version + "'";
            System.Data.OleDb.OleDbCommand temp_OleDbCommand = new System.Data.OleDb.OleDbCommand();
            temp_OleDbCommand.Connection = conn;
            temp_OleDbCommand.CommandText = sql;
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList segments = new System.Collections.ArrayList();
            while (rs.Read())
            {
                System.String segName = System.Convert.ToString(rs[1 - 1]);
                if (System.Char.IsLetter(segName[0]))
                    segments.Add(altSegName(segName));
            }
            //UPGRADE_ISSUE: Method 'java.sql.Statement.close' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javasqlStatementclose'"
            temp_OleDbCommand.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            if (segments.Count == 0)
            {
                //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
                log.warn("No version " + version + " segments found in database " + conn.Database);
            }

            for (int i = 0; i < segments.Count; i++)
            {
                try
                {
                    System.String seg = (System.String) segments[i];
                    System.String source = makeSegment(seg, version);
                    //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
                    //UPGRADE_TODO: Constructor 'java.io.FileWriter.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriterFileWriter_javalangString_boolean'"
                    //UPGRADE_TODO: Class 'java.io.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriter'"
                    using(System.IO.StreamWriter w = new System.IO.StreamWriter(targetDir.ToString() + "/" + seg + ".cs"))
                    {
                        w.Write(source);
                        w.Write("}");//Ending namespace
                    }
                }
                catch (System.Exception e)
                {
                    //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                    System.Console.Error.WriteLine("Error creating source code for all segments: " + e.Message);
                    SupportClass.WriteStackTrace(e, Console.Error);
                }
            }
        }
开发者ID:snosrap,项目名称:nhapi,代码行数:63,代码来源:SegmentGenerator.cs


注:本文中的System.Data.OleDb.OleDbCommand.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。