日期:2014-05-17 浏览次数:20473 次
using (System.Data.SqlClient.SqlCommand sqlcmd1 = new System.Data.SqlClient.SqlCommand("select * from [Tbl_users]", SQLconn))
{
sqlcmd1.CommandType = System.Data.CommandType.Text;
SqlDataAdapter sda = new SqlDataAdapter(sqlcmd1);
DataTable dt = new DataTable();
sda.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
mdbcmd1.Parameters.Clear();
mdbcmd1.Parameters.AddWithValue("@[username]", dt.Rows[i]["username"].ToString());
mdbcmd1.Parameters.AddWithValue("@[phone]", dt.Rows[i]["phone"].ToString());
mdbcmd1.Parameters.AddWithValue("@[birthday]", dt.Rows[i]["birthday"].ToString());
mdbcmd1.Parameters.AddWithValue("@[address]", dt.Rows[i]["address"].ToString());
mdbcmd1.ExecuteNonQuery();
}
}