raj aryan

raj aryan

  • NA
  • 26
  • 20.8k

want to export data to the sql server database table

Mar 13 2013 6:02 AM
Hello folks,

I am working on desktop application in c#.net. I have 1 ODBC connection that gives me third party application data into gridview(on 1st button click). Now my task is to dump(export) the data, whatever in the grid, into sqlserver database table(I created the 1 table for sample purpose with the column's name), on 2nd button click. Let me know the procedure in c# to overcome this issue.

here is the code let me know the solution please....
public void export_Click(object sender, EventArgs e)
        {
            try
            {
             
                string connetionString = "sql database connectionstring";
               
                "what to writehere".datasource= model.GetView("Query", txtQuery.Text); //odbc connectionstring
                SqlConnection cnn = new SqlConnection(connetionString);
                cnn.Open();
                string sql = "INSERT Query to get the data from odbc connection and dump the data into sql server database table")";
                  SqlCommand cmd = new SqlCommand(sql, cnn); 
             
                            cmd.ExecuteNonQuery();


            }
            catch (Exception ex)
            {


            }
        }


Regards,
Raj

Answers (1)