Database Reference
In-Depth Information
this.Hide();
}
catch (SqlException sqlEX)
{
MessageBox.Show(sqlEX.Message);
}
}
private void button2_Click(object sender,
EventArgs e)
{
DataSet ds = new DataSet();
string SqlConnStr = “Data Source =.;Initial
Catalog = test;Integrated Security = SSPI;”;
SqlConnection SqlConn = new
SqlConnection(SqlConnStr);
SqlConn.Open();
string SqlStr = “select * from Table 1”;
SqlCommand SqlCmd = new SqlCommand(SqlStr,
SqlConn);
SqlDataAdapter Adpt = new SqlDataAdapter(SqlCmd);
Adpt.Fill(ds);
SqlConn.Close();
for (int i = 1; i < = 5; i++)
{
foreach (DataRow DBrow in
ds.Tables 0].Rows)
{
string SqlConnStr1 = “Data Source =.;
Initial Catalog = “ + DBrow[0].
ToString() + “;Integrated Security
= SSPI;”;
SqlConnection mSqlConnection1 = new
SqlConnection(SqlConnStr1);
//the primary key column resides at
index 4
string str1 = “insert into [“ +
DBrow[1].ToString() + “] select *
from
[“ + DBrow[1].ToString() + “]”;
mSqlConnection1.Open();
SqlCommand mSqlCommand1 = new
SqlCommand(str1,
mSqlConnection1);
mSqlCommand1.CommandTimeout = 200;
mSqlCommand1.ExecuteNonQuery();
Search WWH ::




Custom Search