Insert Statement using OdbcCommand - CSharp Database

CSharp examples for Database:ODBC

Description

Insert Statement using OdbcCommand

Demo Code


using System.Data.Odbc;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//www . j  a  va  2  s  . c om

public class Main{
        internal static void InsertSymbolPrice(string symbol, double price)
        {
            OdbcConnection con = new OdbcConnection(Constants.MyConString);
            try
            {

                OdbcCommand com = new OdbcCommand("INSERT INTO symbolperformance (symbol,Previousdayprice) values('" + symbol + "'," + price + ")", con);


                con.Open();
                com.ExecuteNonQuery();
                

                con.Close();

            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            finally
            {
                if (con != null)
                    con.Close();
            }

        }
}

Related Tutorials