public class MDFtoMDF : IDisposable { public int cid { get; set; } public string cdt { get; set; } public string cc1 { get; set; } public string cc2 { get; set; } public string cc3 { get; set; } public void Dispose() { Dispose(true); } private void Dispose(bool disposable) { if (disposable) { // Free resources } // Prevents the destructor to be called if dispose is called. GC.SuppressFinalize(this); } }
protected void Button1_Click(object sender, EventArgs e) { //ArrayList list = new ArrayList(); using (MDFtoMDF test = new MDFtoMDF()) { Int16 n = 0; String connStr = ConfigurationManager.ConnectionStrings["From"].ConnectionString; String cmdStr = "SELECT * FROM [Table2];"; try { using (SqlConnection conn = new SqlConnection(connStr)) { using (SqlCommand cmd = new SqlCommand(cmdStr, conn)) { conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { dr.Read(); n += 1; test.cid = n + 3; test.cdt = (dr[1].ToString()); test.cc1 = (dr[2].ToString()); test.cc2 = (dr[3].ToString()); test.cc3 = (dr[4].ToString()); } conn.Close(); cmd.Dispose(); conn.Dispose(); } } } catch (Exception ex) { TextBox1.Text = ex.Message; } using (MDFtoMDF test = new MDFtoMDF()) { for (int i = 0; i <= n-1; i++) { int16 dataid = test.cid[i]; string datadatetime = test.cdt[i]; string datacol1 = test.cc1[i]; string datacol2 = test.cc2[i]; string datacol3 = test.cc3[i]; //SQL INSERT INTO } }
Quote: while (dr.Read()) { n += 1; test.cid = n + 3; test.cdt = (dr[1].ToString()); test.cc1 = (dr[2].ToString()); test.cc2 = (dr[3].ToString()); test.cc3 = (dr[4].ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)