请问ACCESS里如何把一个字段下面的全部数据都删除呢?
就是前两个下面的数据保留,只把后面的数据全部清0,请问在access2003中该如何操作呢?谢谢!!!...
就是前两个下面的数据保留,只把后面的数据全部清0,请问在access2003中该如何操作呢?谢谢!!!
展开
3个回答
展开全部
Public Function TransactSQL(ByVal sql As String) As ADODB.Recordset
Dim cont As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConnection As String
Dim strArray() As String
Set cont = New ADODB.Connection '创建连接
Set rs = New ADODB.Recordset
On Error GoTo transactsql_error
strConnection = "Provider = Microsoft.jet.oledb.4.0; data source=" & App.Path & "\cd1.mdb;"
strConnection = strConnection & "Persist Security Info=False;"
strArray = Split(sql) 'Split() 返回一个下标从零开始的一维数组
cont.Open strConnection '打开连接
If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
rs.Open Trim$(sql), cont, adOpenKeyset, adLockOptimistic
Set TransactSQL = rs
iflag = 1
Else
cont.Execute sql
iflag = 1
End If
transactsql_exit:
Set rs = Nothing
Set cont = Nothing
Exit Function
transactsql_error:
MsgBox "查询错误:" & Err.Description
iflag = 2
Resume transactsql_exit
End Function
上面这个是一个数据库的动态链接,这块代码在模块里放着.
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from Lendcx" 'Lendcx是表名
Set rs = TransactSQL(sql)
rs.AddNew '添加新纪录
rs.Fields(0) = Trim(Combo3.Text)
rs.Fields(1) = Trim(Combo1.Text)
rs.Fields(2) = Trim(DTPicker1.Value)
rs.Fields(3) = Trim(Combo2.Text)
rs.Fields(4) = Trim(Text2.Text)
rs.Fields(5) = Trim(text3.Text)
rs.Update
rs.Close
你可以参考一下看看!
Dim cont As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConnection As String
Dim strArray() As String
Set cont = New ADODB.Connection '创建连接
Set rs = New ADODB.Recordset
On Error GoTo transactsql_error
strConnection = "Provider = Microsoft.jet.oledb.4.0; data source=" & App.Path & "\cd1.mdb;"
strConnection = strConnection & "Persist Security Info=False;"
strArray = Split(sql) 'Split() 返回一个下标从零开始的一维数组
cont.Open strConnection '打开连接
If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
rs.Open Trim$(sql), cont, adOpenKeyset, adLockOptimistic
Set TransactSQL = rs
iflag = 1
Else
cont.Execute sql
iflag = 1
End If
transactsql_exit:
Set rs = Nothing
Set cont = Nothing
Exit Function
transactsql_error:
MsgBox "查询错误:" & Err.Description
iflag = 2
Resume transactsql_exit
End Function
上面这个是一个数据库的动态链接,这块代码在模块里放着.
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from Lendcx" 'Lendcx是表名
Set rs = TransactSQL(sql)
rs.AddNew '添加新纪录
rs.Fields(0) = Trim(Combo3.Text)
rs.Fields(1) = Trim(Combo1.Text)
rs.Fields(2) = Trim(DTPicker1.Value)
rs.Fields(3) = Trim(Combo2.Text)
rs.Fields(4) = Trim(Text2.Text)
rs.Fields(5) = Trim(text3.Text)
rs.Update
rs.Close
你可以参考一下看看!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
update .. set .. = 0 就行了,不过你最好先备份,再操作!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |