更新SQL数据库问题
private void button3_Click(object sender, EventArgs e)
{int i=0;
string strConn = ConfigurationManager.ConnectionStrings["字符串"].ConnectionString;
SqlConnection myConn = new SqlConnection(strConn);
string upSQL = " select lat,lng from shuju ";
myConn.Open();
SqlCommand myCommand1 = new SqlCommand(upSQL, myConn);
SqlDataAdapter adapter1 = new SqlDataAdapter(myCommand1);
adapter1.SelectCommand = new SqlCommand(upSQL,myConn);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter1);
DataSet ds1 = new DataSet();
adapter1.Fill(ds1);
DataTable dt1 = ds1.Tables[0];
for(i=0;i<dt1.Rows.Count;i++){
dt1.Rows[i][0] = 22.22;
}
adapter1.Update(dt1);
myConn.Close();
}
数据库的表里是有主键的 字段名为id
为什么更新不了呢
------解决方案--------------------
select lat,lng,id from shuju