Copy data from ODBCconnection to SQLSTATMENT

Mar 30 2014 8:30 AM
I want to copy my data from OdbcConnection to SqlStatment thru C# code. Thru one button I want to do this...
I'm not much expert in c# but just little bit programming, can some one add/edit some codes our statement/help so i can complete my program.

I do thru this code but data is not fetching....


protected void Button1_Click(object sender, EventArgs e)
{
this.cn = new OdbcConnection();
this.Jda_Cmd = new OdbcCommand();
this.Jda_Cmd.Connection = this.cn;
this.cn.ConnectionString = "DSN=Imports_Img;UserID=ODBCCOMN;Password=pkli7491;Data Source=172.16.4.5;Transport Product=Client Access;SSL=DEFAULT;DEFAULT COLLECTION='BINDAWOOD'";
string str = ("SELECT ibhand FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND ISTORE=14");
this.Jda_Cmd.CommandText = str;
{
this.cn.Open();
OdbcDataReader reader2 = this.Jda_Cmd.ExecuteReader();
//connection2.Open();
while (reader2.Read())
{
this.DB_Cmd = new SqlCommand();
this.DB_Cmd.Connection = this.DB_cn;
SqlConnection connection2 = new SqlConnection();
SqlCommand db_cn = new SqlCommand ("insert into invbaldb ('sku') values ('" + reader2[0] + "')", connection2);
//SqlCommand command2 = new SqlCommand("insert into invbaldb ('sku') values ('" + reader2[0] + "')", connection2);
//DB_cn.ExecuteNonQuery();
db_cn.ExecuteNonQuery();
}
reader2.Close();
//connection2.Close();
}
}

Answers (1)