Update Statement using OdbcCommand - CSharp Database

CSharp examples for Database:ODBC

Description

Update Statement using OdbcCommand

Demo Code


using System.Data.Odbc;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   ww  w  .j ava  2 s  .c  o m

public class Main{
        internal static void UpdateSymbolPerformance()
        {
            OdbcConnection con = new OdbcConnection(Constants.MyConString);
            try
            {
                OdbcCommand com = new OdbcCommand("UPDATE symbolperformance temp1, "+
                                                "(SELECT p.symbol,(your data)" +
                                                "FROM symbolperformance AS p JOIN symbolanalytics AS a  "+
                                                "ON p.symbol=a.symbol) temp2 "+
                                                "SET temp1.ytdpct=temp2.ytd, temp1.qtdpct=temp2.qtd " +
                                                "WHERE temp1.symbol=temp2.symbol", con);


                con.Open();
                com.ExecuteNonQuery();
                log.Info("\nData updated in symbolperformance table....... \n");

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

Related Tutorials