我们软件工程要做一个排刻的作业,问几个很菜的数据库问题(白拿高分,我的可用分很多的)

ebombsuhocom 2001-11-15 08:09:51
1,DBGRID控件和DATA控件关联了以后,怎样删除一条记录
2,怎样通过SQL查询后,将所以符合条见的记录一条条列出来
3,用DAO API怎样创建表,FIELD等,怎样把所有记录都删掉.
4,得到的记录怎样把其中对应的不同的FIELD的值得到(通过FIELD的名字)
...全文
66 5 点赞 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
foolishtiger 2001-11-16
(摘自MSDN)
Sub AppendX()

Dim dbsNorthwind As Database
Dim tdfEmployees As TableDef
Dim fldLoop As Field

Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set tdfEmployees = dbsNorthwind.TableDefs!Employees

' Add three new fields.
AppendDeleteField tdfEmployees, "APPEND", _
"E-mail", dbText, 50
AppendDeleteField tdfEmployees, "APPEND", _
"Http", dbText, 80
AppendDeleteField tdfEmployees, "APPEND", _
"Quota", dbInteger, 5

Debug.Print "Fields after Append"

Debug.Print , "Type", "Size", "Name"

' Enumerate the Fields collection to show the new fields.
For Each fldLoop In tdfEmployees.Fields
Debug.Print , fldLoop.Type, fldLoop.Size, fldLoop.Name
Next fldLoop

' Delete the newly added fields.
AppendDeleteField tdfEmployees, "DELETE", "E-mail"
AppendDeleteField tdfEmployees, "DELETE", "Http"
AppendDeleteField tdfEmployees, "DELETE", "Quota"

Debug.Print "Fields after Delete"
Debug.Print , "Type", "Size", "Name"

' Enumerate the Fields collection to show that the new
' fields have been deleted.
For Each fldLoop In tdfEmployees.Fields
Debug.Print , fldLoop.Type, fldLoop.Size, fldLoop.Name
Next fldLoop

dbsNorthwind.Close

End Sub

Sub AppendDeleteField(tdfTemp As TableDef, _
strCommand As String, strName As String, _
Optional varType, Optional varSize)

With tdfTemp

' Check first to see if the TableDef object is
' updatable. If it isn't, control is passed back to

' the calling procedure.
If .Updatable = False Then
MsgBox "TableDef not Updatable! " & _
"Unable to complete task."
Exit Sub
End If

' Depending on the passed data, append or delete a
' field to the Fields collection of the specified
' TableDef object.
If strCommand = "APPEND" Then
.Fields.Append .CreateField(strName, _
varType, varSize)
Else
If strCommand = "DELETE" Then .Fields.Delete _

strName
End If

End With

End Sub
  • 打赏
  • 举报
回复
foolishtiger 2001-11-16
1,DBGRID控件和DATA控件关联了以后,怎样删除一条记录
Data1.RecordSet.Delete

2,怎样通过SQL查询后,将所以符合条见的记录一条条列出来
Data1.RecordSource="SQL"
Data1.Refresh

3,用DAO API怎样创建表,FIELD等,怎样把所有记录都删掉.

4,得到的记录怎样把其中对应的不同的FIELD的值得到(通过FIELD的名字)
Data1.RecordSet.Fields("FieldName").Value

  • 打赏
  • 举报
回复
lou_df 2001-11-16
1、点击一条记录的行头,然后按删除键,将该行删除。
2、data1.recordsource="select ..."
data1.refresh
  • 打赏
  • 举报
回复
jshyjyw 2001-11-16
你的问题涉及的面太广了,与其回答你的问题,不如做个程序送给你呢!
  • 打赏
  • 举报
回复
cgb_prince 2001-11-15
你问的不是几个问题,而是整个一套数据库应用程序.
  • 打赏
  • 举报
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2001-11-15 08:09
社区公告
暂无公告