日期:2014-05-17 浏览次数:20862 次
private void Bind2(int Areacode2)
{
SqlConnection scConnection = new SqlConnection(connstr); //建立Connection
SqlCommand scCommand2 = scConnection.CreateCommand(); //建立Command
scCommand2.CommandText = "select Id,Shipdate,Shipcompany,Company,Portship,Shipday,[20],[40],HQ,Dodate,Endday,Tax,Addcharge,Mark,Areacode1,Areacode2 from zheng where Areacode1=@Areacode1 and Areacode2=@Areacode2";
scCommand2.Parameters.AddWithValue("@Areacode1", area);
scCommand2.Parameters.AddWithValue("@Areacode2", Areacode2);
sdaAdapter2 = new SqlDataAdapter(scCommand2); //建立Adapter
scbBuilder2 = new SqlCommandBuilder(sdaAdapter2); //该对象负责生成用于更新数据库的SQL语句,不必自己创建这些语句
dsSet.Clear(); //使用容器前先清空容器
sdaAdapter2.Fill(dsSet, "zheng"); //填充数据
bind2 = this.BindingContext[dsSet.Tables["zheng"]];
dataGridView2.DataSource = dsSet.Tables["zheng"]; //数据源绑定
}