• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Odbc.OdbcCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.Odbc.OdbcCommand的典型用法代码示例。如果您正苦于以下问题:C# OdbcCommand类的具体用法?C# OdbcCommand怎么用?C# OdbcCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OdbcCommand类属于System.Data.Odbc命名空间,在下文中一共展示了OdbcCommand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: insert

        /// <summary>
        /// ��Ʈw�s�W��k
        /// </summary>
        /// <param name="insert"></param>
        public void insert(ICommand insert)
        {
            string myCmd = insert.getCommand();
            try
            {
                cmd = new OdbcCommand(myCmd, GetConn());
                //cmd = new IBM.Data.DB2.DB2Command(myCmd, GetConn());
                cmd.ExecuteNonQuery();
            }
            catch (OdbcException dobcEx)
            {
                if (dobcEx.ErrorCode == -2146232009)
                {
                    return;
                }

                try
                {
                    lock (typeof(OdbcConnection))
                    {
                        //cmd = new IBM.Data.DB2.DB2Command(myCmd, GetConn());
                        cmd = new OdbcCommand(myCmd, GetConn());
                        cmd.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:35,代码来源:A_OdbcConnect.cs


示例2: getAllAuspiciantes

    public static List<Auspiciante> getAllAuspiciantes()
    {
        OdbcConnection con = ConexionBD.ObtenerConexion();
        DataSet ds = new DataSet();
        List<Auspiciante> listaAuspiciantes = new List<Auspiciante>();
        try
        {
            OdbcCommand cmd = new OdbcCommand("SELECT a.id, a.imagen FROM auspiciante a", con);
            cmd.CommandType = CommandType.Text;
            OdbcDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Auspiciante a = new Auspiciante();
                a.IdAuspiciante = dr.GetInt32(dr.GetOrdinal("id"));
                a.ImagenAuspiciante = ImagenDAL.getImagen(con,dr.GetInt32(dr.GetOrdinal("imagen")));

                listaAuspiciantes.Add(a);
            }
        }
        catch (Exception e)
        {
            throw new SportingException("Ocurrio un problema al intentar obtener los auspiciantes. " + e.Message);
        }
        return listaAuspiciantes;
    }
开发者ID:branux,项目名称:sporting-pag-web,代码行数:26,代码来源:MultimediaDAL.cs


示例3: inserir

 public int inserir(Voos voo)
 {
     OdbcCommand comando;
     int result = 0;
     String comand = "INSERT INTO voo(codigo, data, origem, destino) VALUES(?, ?, ?, ?)";
     OdbcParameter codigo = new OdbcParameter("?", voo.Codigo);
     OdbcParameter data = new OdbcParameter("?", voo.Data);
     OdbcParameter origem = new OdbcParameter("?", voo.Origem);
     OdbcParameter destino = new OdbcParameter("?", voo.Destino);
     try
     {
         comando = new OdbcCommand(comand, conexao);
         comando.Connection.Open();
         comando.Parameters.Add(codigo);
         comando.Parameters.Add(data);
         comando.Parameters.Add(origem);
         comando.Parameters.Add(destino);
         result = comando.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
     finally
     {
         conexao.Close();
     }
     return result;
 }
开发者ID:abnermsantos,项目名称:CompanhiaAerea,代码行数:29,代码来源:VoosDAO.cs


示例4: Find

        /// <summary>
        /// Use the Username property to fill in the remainder of the fields if the User exists in the database.
        /// </summary>
        /// <returns>True, if the record was found. Else the return value will be false.</returns>
        public bool Find()
        {
            string mySelectQuery = "select AES_DECRYPT(Password, 'key'), idNumber, UserClass from User where Username = '" + m_Username + "'";

            OdbcConnection myConnection = GetConnection();
            OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);

            myConnection.Open();

            bool recordFound = false;
            OdbcDataReader myReader;
            myReader = myCommand.ExecuteReader(CommandBehavior.SingleRow);
            try
            {
                if (myReader.Read())
                {
                    m_Password = myReader.GetString(0);
                    m_idNumber = myReader.GetInt32(1);
                    m_UserClass = myReader.GetString(2);
                    recordFound = true;
                }
            }
            finally
            {
                myReader.Close();
                myConnection.Close();
            }

            return recordFound;
        }
开发者ID:hadleymj,项目名称:Senior-Design-Fall-2009,代码行数:34,代码来源:UserDAO.cs


示例5: OdbcDataAdapter

		public OdbcDataAdapter (OdbcCommand selectCommand) 
		{
			DeleteCommand = null;
			InsertCommand = null;
			SelectCommand = selectCommand;
			UpdateCommand = null;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:OdbcDataAdapter.cs


示例6: getImagenes

    /// <summary>
    /// Setea la lista de imagenes de una noticia
    /// </summary>
    /// <returns></returns>
    public static List<Imagen> getImagenes(Noticia noticia, OdbcConnection con)
    {
        List<Imagen> listaImagenes = new List<Imagen>();
        OdbcDataReader dr = null;

        String query = "SELECT i.id, i.pathBig, i.pathSmall, i.portada, i.pathMedium FROM imagen i, imagen_x_noticia n WHERE i.id=n.idImagen AND n.idNoticia=" + noticia.IdNoticia;

        try
        {
            OdbcCommand cmd = new OdbcCommand(query, con);
            cmd.CommandType = CommandType.Text;
            dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Imagen imagen = new Imagen();
                imagen.IdImagen = dr.GetInt32(0);
                imagen.PathBig = dr.GetString(1);
                imagen.PathSmall = dr.GetString(2);
                imagen.Portada = dr.GetBoolean(3);
                imagen.PathMedium = dr.GetString(4);
                listaImagenes.Add(imagen);
            }
        }
        catch (Exception e)
        {
            throw new SportingException("Ocurrio un problema al intentar obtener las imagenes de las noticias. " + e.Message);
        }

        return listaImagenes;
    }
开发者ID:branux,项目名称:sporting-pag-web,代码行数:35,代码来源:ImagenDAL.cs


示例7: getDataTableImagenes

    public static DataTable getDataTableImagenes(int id)
    {
        OdbcConnection con = ConexionBD.ObtenerConexion();
        DataSet ds = new DataSet();
        List<Noticia> listaNoticias = new List<Noticia>();
        DataTable dataTable = null;
        try
        {
            OdbcCommand cmd = new OdbcCommand("SELECT i.pathBig, i.pathSmall, i.pathMedium FROM imagen_x_noticia ixn, imagen i" +
            " WHERE ixn.idNoticia = " + id + " AND i.id = ixn.idImagen", con);
            cmd.CommandType = CommandType.Text;

            dataTable = new DataTable();
            OdbcDataAdapter adapter = new OdbcDataAdapter();
            adapter.SelectCommand = cmd;
            adapter.Fill(dataTable);
        }
        catch (Exception e)
        {
            throw new SportingException("Ocurrio un problema al intentar obtener las imagenes de las noticias. " + e.Message);
        }
        finally
        {
            con.Close();
        }
        return dataTable;
    }
开发者ID:branux,项目名称:sporting-pag-web,代码行数:27,代码来源:ImagenDAL.cs


示例8: Database

 public Database(string connectionString)
 {
     OC = new OdbcConnection(connectionString);
     dbCommand = new OdbcCommand();
     dbCommand.Connection = OC;
     OC.Open();
 }
开发者ID:kukuhheru,项目名称:SIKelasBerbasisSMS,代码行数:7,代码来源:Database.cs


示例9: delete_record

    //delete the record
    public bool delete_record(string id, string date, string warn_code, string level)
    {
        bool stat = false;
        try
        {
            //set up new connection
            OdbcConnection con = getconnection();
            //open the setup coneection
            con.Open();
            //set command
            OdbcCommand cmd = new OdbcCommand("delete  from student_warning  where ADMISSION_NO='" + id + "' and WARN_DATE='" + date + "' and WARNING_CODE='" + warn_code + "' and LEVEL_CODE='" + level + "'", con);
            //execute the command
            cmd.ExecuteNonQuery();
            //set status as true
            stat = true;
            //close the connection
            con.Close();
        }
        catch (Exception ss)
        {
            string s = ss.Message;
            stat = false;

        }
        return stat;
    }
开发者ID:neonmax,项目名称:sims,代码行数:27,代码来源:Student_Warning_DBCONNECT.cs


示例10: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        string[] strArray = new string[5] { "Delhi", "Mumbai", "Kolkata", "Chennai", "Chandigarh" };
        foreach (string str in strArray)
        {
           OdbcConnection oledbConn = new OdbcConnection("DSN=exceldb");
        try
        {
            // Open connection
            oledbConn.Open();

            // Create OleDbCommand object and select data from worksheet Sheet1
            OdbcCommand cmd = new OdbcCommand("SELECT * FROM [Details$]", oledbConn);
            //cmd.Parameters.AddWithValue("@city",str);where [email protected]
            // Create new OleDbDataAdapter
            OdbcDataAdapter oleda = new OdbcDataAdapter();

            oleda.SelectCommand = cmd;

            // Create a DataSet which will hold the data extracted from the worksheet.
            // DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            // Fill the DataSet from the data extracted from the worksheet.
            oleda.Fill(dt);
            /*      if(dt.Rows.Count>0)
                  {
                       ID = dt.Rows[0]["ID"].ToString(); //Where ColumnName is the Field from the DB that you want to display
                       name= dt.Rows[0]["Name"].ToString();
                       Address = dt.Rows[0]["Address"].ToString();
                       EmailAddress = dt.Rows[0]["emailaddress"].ToString();
                       if(EmailAddress!=null)
                       {
                        if(EmailAddress==)
                       }
                       EmailContent = dt.Rows[0]["emailcontent"].ToString();
                   }
              */
            DataView dv = new DataView(dt);
            // dv.Sort = "emailcontents";
            // dv.Sort = "Name";

            // Bind the data to the GridView
            Grdexcel.DataSource = dv;
            Grdexcel.DataBind();
            // cmd = new OdbcCommand("delete FROM [ter$] where Address like 'M%'", oledbConn);
            // cmd.ExecuteNonQuery();
            //cmd.CommandType
        }
        catch (Exception ex)
        {
            Alert.Show("Sorry");
        }
        finally
        {
            // Close connection
            oledbConn.Close();
        }
        }
    }
开发者ID:nitishpandey,项目名称:semiprecious,代码行数:60,代码来源:excelsheet.aspx.cs


示例11: addUser

        private String addUser()
        {
            try
            {
                Contract contract = new Contract();
                String cxnString = "Driver={SQL Server};Server=HC-sql7;Database=REVINT;Trusted_Connection=yes;";
                using (OdbcConnection dbConnection = new OdbcConnection(cxnString))
                {
                    //open OdbcConnection object
                    dbConnection.Open();

                    OdbcCommand cmd = new OdbcCommand();

                    cmd.CommandText = "{CALL [REVINT]." + contract.getSchema() + ".[OCP_addUser]( ?, ?, ?, ? )}";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection = dbConnection;

                    cmd.Parameters.Add("@hawkId", OdbcType.NVarChar, 400).Value = txtHealthcareID.Text;
                    cmd.Parameters.Add("@administrator", OdbcType.Bit).Value = chkAdmin.IsChecked;
                    cmd.Parameters.Add("@name", OdbcType.NVarChar, 400).Value = txtName.Text;
                    cmd.Parameters.Add("@numRecords", OdbcType.Int);
                    cmd.Parameters["@numRecords"].Direction = System.Data.ParameterDirection.ReturnValue;

                    cmd.ExecuteNonQuery();

                    dbConnection.Close();

                    return cmd.Parameters["@numRecords"].Value.ToString();
                }
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:ep2012,项目名称:OCP-2.0,代码行数:35,代码来源:AddUser.xaml.cs


示例12: AddTermCode

    public bool AddTermCode(TermCode termCode)
    {
        bool result = false;

        using (OdbcConnection connection = new OdbcConnection(connectionString))
        {
            using (OdbcCommand command = new OdbcCommand())
            {
                command.Connection = connection;
                command.CommandText = "{CALL TermCode_insert(?,?)}";
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@AssessmentOID", termCode.AssessmentOID);
                command.Parameters.AddWithValue("@TermCodeName", termCode.TermCodeName);
                connection.Open();
                int n = command.ExecuteNonQuery();
                if (n > 0)
                    result = true;
                else
                    result = false;
            }
        }

        return result;
    }
开发者ID:mominbd,项目名称:testing,代码行数:25,代码来源:TermCode.cs


示例13: Button1_Click1

    protected void Button1_Click1(object sender, EventArgs e)
    {
        int i;
        string htmlstr = "<table style='width:100%;'>";
        string data;
        string sql = TextBox1.Text;
        string constr = Session["connection"].ToString();
        OdbcConnection cn = new OdbcConnection(constr);
        cn.Open();
        OdbcCommand cmd = new OdbcCommand(sql, cn);
        OdbcDataReader reader;
        reader = cmd.ExecuteReader();
        int col_count = reader.FieldCount;
        int count1;

        while (reader.Read())
        {
            htmlstr += "<tr>";
            count1 = col_count;
            i = 0;
            while (count1 != 0)
            {
                data = reader[i].ToString();
                htmlstr += "<td class='style2'>" + data + "</td>";
                count1--;
                i++;
            }
            htmlstr += "</tr>";
        }
        htmlstr += "</table>";
        table_data.InnerHtml = htmlstr;
    }
开发者ID:ashishvshenoy,项目名称:Insurance-DBMS-2,代码行数:32,代码来源:ReportPage.aspx.cs


示例14: Load_Sport_GR_TB_TXT_TO_DB

        public static void Load_Sport_GR_TB_TXT_TO_DB(string table_name,string field_names)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                using (OdbcConnection conn = new OdbcConnection(Basic_HTB_Info.Conn_Str))
                {
                    conn.Open();
                    MessageBox.Show(String.Format("TRUNCATE TABLE {0};",table_name));
                    using (OdbcCommand cmd = new OdbcCommand(String.Format("TRUNCATE TABLE {0};",table_name), conn))
                    {
                        cmd.ExecuteNonQuery();
                    }
                    StreamReader sr = new StreamReader(ofd.FileName);
                    string line = null;
                    while ((line = sr.ReadLine()) != null)
                    {

                        string[] str_a = line.Split(',');
                        if (str_a.Length > 5)
                        {
                            Lib.inc_cmd(field_names, table_name, str_a, conn);
                        }
                    }
                    conn.Close();
                }
            }
        }
开发者ID:eddylin2015,项目名称:sportday,代码行数:28,代码来源:Lib.cs


示例15: ExecutaComando

 /// <summary>
 /// Executa algum comando de inserção, exclusão ou edição
 /// </summary>
 /// <param name="sql">o sql a ser executado</param>
 public void ExecutaComando(string sql)
 { 
     //Usa a classe de conexão apenas nesse bloco
     using(OdbcConnection conn = new OdbcConnection(this.ConnectionString))
     {
         try
         {   
             //Abre conexão com o servidor de banco
             conn.Open();
             //instancia um objeto de comando, passando como parametro o sql e a conexão para o construtor
             OdbcCommand comm = new OdbcCommand(sql, conn);
             //Executa o comando
             comm.ExecuteNonQuery();
         }
         catch (Exception ex)
         {   
             //Atira uma nova excessão, caso dê algum erro
             throw new Exception(ex.Message);
         }
         finally
         {   
             //Sempre fechará conexão, independente se der erro ou não
             conn.Close();
         }
     }
 }
开发者ID:dielduarte,项目名称:votaai,代码行数:30,代码来源:Conexao.cs


示例16: delete_record

 //this function deletes the selected  record
 public bool delete_record(string student_id)
 {
     bool stat = false;
     try
     {
         //get the connection
         OdbcConnection con = connect.getconnection();
         //open the created connection
         con.Open();
         //create new sql command
         OdbcCommand cmd = new OdbcCommand("delete from  student_warning where ADMISSION_NO='" + student_id + "'", con);
         //execute the quary
         cmd.ExecuteNonQuery();
         //if quary excecution is success the  change stat as true
         stat = true;
     }
     catch (Exception ss)
     {
         string dd = ss.ToString();
         Response.Write("<script>alert('Error while processing, Please try again')</script>");
     }
     finally
     {
         connect.close();
     }
     return stat;
 }
开发者ID:neonmax,项目名称:sims,代码行数:28,代码来源:WUC_StudentWarning.ascx.cs


示例17: castProvider

 /// <summary>
 /// initialization casting for InitializeDataAccess()
 /// </summary>
 /// <param name="type"></param>
 /// <param name="ConnectionString"></param>
 /// <param name="Query"></param>
 private void castProvider(ProviderType type, string ConnectionString, string Query = null)
 {
     switch (type)
     {
         case ProviderType.Oledb:
             conn = new OleDbConnection(ConnectionString);
             cmd = new OleDbCommand(Query, (OleDbConnection)conn);
             da = new OleDbDataAdapter();
             break;
         case ProviderType.Odbc:
             conn = new OdbcConnection(ConnectionString);
             cmd = new OdbcCommand(Query, (OdbcConnection)conn);
             da = new OdbcDataAdapter();
             break;
         case ProviderType.SqlClient:
             conn = new SqlConnection(ConnectionString);
             cmd = new SqlCommand(Query, (SqlConnection)conn);
             da = new SqlDataAdapter();
             break;
         //case ProviderType.OracleClient:
         //    conn = new OracleConnection(ConnectionString);
         //    cmd = new OracleCommand(Query,(OracleConnection)conn);
         //    break;
     }
 }
开发者ID:reciosonny,项目名称:Data-Access-Layer-Centralization-using-ADO.net,代码行数:31,代码来源:DataAccessPrivateMethods.cs


示例18: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        //   string ImageId = System.Convert.ToString(Request.QueryString["name"]);

        int articleID = System.Convert.ToInt32(Request.QueryString["textid"]);

        string MyConString = ConfigurationSettings.AppSettings["connectionString"];

        OdbcConnection connection = new OdbcConnection(MyConString);

        string sqlNews1 = "select * FROM latestnews";
        OdbcCommand commandNews1 = new OdbcCommand(sqlNews1, connection);
        connection.Open();
        OdbcDataReader dr = commandNews1.ExecuteReader(CommandBehavior.CloseConnection);

        if (dr.Read())
        {
            Response.ContentType = dr["date"].ToString();
            Response.ContentType = dr["title"].ToString();
            Response.ContentType = dr["content"].ToString();

        }
        connection.Close();

        string selectNews = "SELECT date, title, content FROM latestnews ORDER BY date DESC";
        OdbcCommand command = new OdbcCommand(selectNews, connection);
        OdbcDataAdapter adapter = new OdbcDataAdapter(command);
        DataSet ds = new DataSet();

        adapter.Fill(ds);

        DataList1.DataSource = ds;
        DataList1.DataBind();
    }
开发者ID:hyori7,项目名称:Yspace,代码行数:34,代码来源:News.aspx.cs


示例19: Main

        static void Main(string[] args)
        {
            //"DRIVER={MySQL ODBC 5.2w Driver};SERVER=localhost;DATABASE=config;UID=root;PASSWORD=liu355dq;"

            string MyConString = "DRIVER={MySQL ODBC 5.2w Driver};" +

                               "SERVER=localhost;" +

                               "DATABASE=g_db;" +

                               "UID=root;" +

                               "PASSWORD=liu355dq;";

            OdbcConnection myconnection = new OdbcConnection(MyConString);
            OdbcCommand cmd = new OdbcCommand("select * from g_operator");
            cmd.Connection = myconnection;
            myconnection.Open();
            OdbcDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Console.WriteLine(reader[1]);
            }
            myconnection.Close();

            Console.ReadKey();
        }
开发者ID:budlion,项目名称:DSTPRJ,代码行数:27,代码来源:Program.cs


示例20: btnSignIn_Click

        private void btnSignIn_Click(object sender, EventArgs e)
        {
            OdbcConnection Conn = new OdbcConnection("DSN=ora10glocal;uid=TTCS;PWD=Pass1234");
            OdbcCommand cmd = new OdbcCommand("SELECT EMPLOYEEPASSWORD FROM EMPLOYEE WHERE LASTNAME = '" + txtUserName.Text + "'AND EMPLOYEETYPE = 'Foreman';", Conn);
            Conn.Open();
            Object EmpPass = cmd.ExecuteScalar();
            cmd.Dispose();
            Conn.Close();

            if (txtUserName.Text == "")
            {
                MessageBox.Show("User name is empty!");
            }
            else if (Convert.ToString(EmpPass) == "")
            {
                MessageBox.Show("Password is empty!");
            }
            else if (Convert.ToString(EmpPass) != txtPassword.Text)
            {
                MessageBox.Show("Wrong password! please type again!");
            }
            else
            {
                string Emp = Convert.ToString(EmpPass);
                var frm = new Form1(Emp);
                frm.ShowDialog();
                //this.Visible = false
            }
        }
开发者ID:NickReid89,项目名称:TrailerTrafficControlSystemSimulator,代码行数:29,代码来源:SignIn.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Odbc.OdbcConnection类代码示例发布时间:2022-05-26
下一篇:
C# Odbc.ODBC32类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap