想删除符合条件的记录,这么写行么?
DelAllRecord.Open "select * from 调动信息 where 员工编号= ' " & CmbCodeID.Text & " ' ", DBCON, adOpenKeyset, adLockPessimistic, adCmdText
while DelAllRecord.EOF
DelAllRecord.Delete
' 这里是不是要什么语句,让记录集的指针向下移?
Endw
DelAllRecord.Close
[解决办法]
用ADO控件最简单:
DatabaseLinkStr= "Provider=SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=sa;Initial Catalog=databasename;Data Source=127.0.0.1 "
Adodc1.ConnectionString = DatabaseLinkStr
Adodc1.RecordSource = "delete from 调动信息 where 员工编号= ' " & CmbCodeID.Text & " ' "
Adodc1.Refresh
[解决办法]
上面樓主的操作太麻煩了,
一般簡單的添加刪除操作只需用execute 事件就行了
這種簡單操作最好用
全局聲明
public sqlconn as adodb.connection
set sqlconn= new adodb.connection
sqlconn.connectionstring = "Provider=SQLOLEDB;Data Source= " & ipstr & ";User ID=appuser;Password=hferp;Initial Catalog=ERP "
sqlconn.Open
sqlconn.execute "delete from 调动信息 where 员工编号= ' " & CmbCodeID.Text & " ' "
[解决办法]
sqlconn.execute "delete from 调动信息 where 员工编号= ' " & CmbCodeID.Text & " ' "
这个比较高效