Ken

Ken

  • NA
  • 35
  • 0

Newbie - Trying to insert data into sql table from a dataset

Jun 17 2008 7:16 PM
Here is the scenario I have 2 seperate SQL servers on a LAN.  I need to get data from one server and insert into a table on another server.  I am using a dataset to get the data and now am stuck on how to insert it into the other instance of SQL.  The code below is working....Thanks in advance....

private void btnOnclick(object sender, EventArgs e)
        {
    
           
            // creating connection to Timeforce
            SqlConnection conn = new SqlConnection("Data Source= 192.168.1.225\\BBTSQL;Initial Catalog=qqest;User Id =sa;Password =xxx");
          
           
             //  OPENING CONNECTION
            conn.Open();

            //  EXECUTING PROC TO GET DATA

            SqlCommand Execproc = new SqlCommand("sp_TimeVacSic", conn);
            Execproc.CommandType = CommandType.StoredProcedure;
            Execproc.ExecuteNonQuery();

            //Getting Data for Dataset

            SqlDataAdapter SQLAdp = new SqlDataAdapter("Select * from gpsvacsic", conn);
            DataSet dsVacSic = new DataSet();


            //Closing connection
            conn.Close();

            //Filling the Dataset

            SQLAdp.Fill(dsVacSic, "VacSic");
    
           // Need to make second connection but not sure syntax for inserting into table

Answers (2)