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

ebombsuhocom 2001-11-15 08:09:51
1,DBGRID控件和DATA控件关联了以后,怎样删除一条记录
2,怎样通过SQL查询后,将所以符合条见的记录一条条列出来
3,用DAO API怎样创建表,FIELD等,怎样把所有记录都删掉.
4,得到的记录怎样把其中对应的不同的FIELD的值得到(通过FIELD的名字)
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
  • 打赏
  • 举报
回复
你问的不是几个问题,而是整个一套数据库应用程序.

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧