[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
public virtual int UpdateExamples() {
global::System.Data.OleDb.OleDbCommand command = this.CommandCollection[2];
global::System.Data.ConnectionState previousConnectionState = command.Connection.State;
if (((command.Connection.State & global::System.Data.ConnectionState.Open)
!= global::System.Data.ConnectionState.Open)) {
command.Connection.Open();
}
int returnValue;
try {
returnValue = command.ExecuteNonQuery();
}
finally {
if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) {
command.Connection.Close();
}
}
return returnValue;
}
先说一下我的使用环境:vs2005,access2003
我根本就未有使用参数,而这个UpdateExamples也是机器生成的代码,在设计视图->查询生成器里面我的sql代码可以执行,能更新数据到access,但是我调用这个函数,能返回更新的函数大于1,但是重新打开access里面的内容根本就没有遍,我简直是要崩溃了,这几天都在搞更新的问题,是不是还得调用什么东西使数据库更新的啊?求求各位大大能解决一下了,感激不尽!
下面是_commandCollection[2](即CommandCollection[2])的定义:
this._commandCollection[2] = new global::System.Data.OleDb.OleDbCommand();
this._commandCollection[2].Connection = this.Connection;
this._commandCollection[2].CommandText = "UPDATE zgz\r\nSET xm = \'测试者2\', xb = \'女\'\r\nWHERE (xm = \'测试者\')";
this._commandCollection[2].CommandType = global::System.Data.CommandType.Text;
[global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
public virtual int UpdateExamples() {
global::System.Data.OleDb.OleDbCommand command = this.CommandCollection[2];
global::System.Data.ConnectionState previousConnectionState = command.Connection.State;
if (((command.Connection.State & global::System.Data.ConnectionState.Open)
!= global::System.Data.ConnectionState.Open)) {
command.Connection.Open();
}
int returnValue;
try {
returnValue = command.ExecuteNonQuery();
}
finally {
if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) {
command.Connection.Close();
}
}
return returnValue;
}
先说一下我的使用环境:vs2005,access2003
我根本就未有使用参数,而这个UpdateExamples也是机器生成的代码,在设计视图->查询生成器里面我的sql代码可以执行,能更新数据到access,但是我调用这个函数,能返回更新的函数大于1,但是重新打开access里面的内容根本就没有遍,我简直是要崩溃了,这几天都在搞更新的问题,是不是还得调用什么东西使数据库更新的啊?求求各位大大能解决一下了,感激不尽!
下面是_commandCollection[2](即CommandCollection[2])的定义:
this._commandCollection[2] = new global::System.Data.OleDb.OleDbCommand();
this._commandCollection[2].Connection = this.Connection;
this._commandCollection[2].CommandText = "UPDATE zgz\r\nSET xm = \'测试者2\', xb = \'女\'\r\nWHERE (xm = \'测试者\')";
this._commandCollection[2].CommandType = global::System.Data.CommandType.Text;
SQL语句里单引号前为什么要加"\"?
像这个其实都是有成功返回的,就是没有更新到Access里面去这个问题很奇怪,我希望解决的是这个,不知道有谁人能提供参考
try {
returnValue = command.ExecuteNonQuery();
}
这里不是吗?