我用 SqlDataAdapter.Update()出现的问题
static void Main(string[] args)
{
string s= "initial catalog=fucai;data source=.;integrated security=true ";
SqlConnection thisConnection =new SqlConnection(s);
thisConnection.Open();
SqlDataAdapter thisDataAdapter =new SqlDataAdapter( "select id,name from member ",thisConnection);
SqlCommandBuilder thisCommandBuilder =new SqlCommandBuilder(thisDataAdapter);
DataSet thisDataSet =new DataSet();
thisDataAdapter.Fill(thisDataSet, "member ");
thisDataSet.Tables[ "member "].Rows[0][ "name "]= "王鹏11 ";
thisDataAdapter.Update(thisDataSet, "member ");(在这一步出现错误说无法生成动态SQL语句)
thisConnection.Close();
}
------解决方案--------------------你的数据表没主键
------解决方案--------------------没有影射
------解决方案--------------------1、有没有主键
2、像name这样的字段最好表示成[name]
------解决方案--------------------用SqlCommandBuilder有几个限制条件,其中一个就是要求你的数据库中的表要设置有主键...
不然没法动态生成sql语句...