sql,dataGrid,update 问题
int k;
string updstr= "update 基本信息 set 车次= ' "+dataGrid1[0,0].ToString()+ " ',出发时间= ' "+dataGrid1[0,1].ToString()+ " ',到达时间= ' "+dataGrid1[0,2].ToString()+ " ',首发站= ' "+dataGrid1[0,3].ToString()+ " ',终点站= ' "+dataGrid1[0,4].ToString()+ " ',主要经过= ' "+dataGrid1[0,5].ToString().Trim()+ " ',备注= ' "+dataGrid1[0,6].ToString().Trim()+ " ',全长= ' "+dataGrid1[0,7]+ " ',经过站数= ' "+dataGrid1[0,8]+ " ' where 车次= ' "+textBox1.Text.Trim()+ " ' ";
string cs= "initial catalog=服务器;data source=(local);integrated security=SSPI; ";
SqlConnection myf=new SqlConnection(cs);
myf.Open();
SqlCommand my1=new SqlCommand();
my1.Connection=myf;
my1.CommandType=CommandType.Text;
my1.CommandText=updstr;
k=my1.ExecuteNonQuery();
各位高手,大哥大姐们,帮我看看这段代码那有问题为什么不能对数据库更新呀???
------解决方案--------------------首页看看你生成的SQL能不能在查询分析器中直接执行