?? frmdelete.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmDelete
BorderStyle = 3 'Fixed Dialog
Caption = "產(chǎn)品刪除"
ClientHeight = 6765
ClientLeft = 45
ClientTop = 330
ClientWidth = 9165
LinkTopic = "Form3"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 6765
ScaleWidth = 9165
ShowInTaskbar = 0 'False
Begin VB.Frame Frame2
Caption = "產(chǎn)品查詢刪除"
Height = 1095
Left = 240
TabIndex = 2
Top = 240
Width = 8655
Begin VB.CommandButton cmdClear
Caption = "清空"
Height = 495
Left = 5160
TabIndex = 8
Top = 360
Width = 1095
End
Begin VB.TextBox txtName
Height = 495
Left = 1680
TabIndex = 6
Top = 360
Width = 1695
End
Begin VB.CommandButton cmdQuery
Caption = "查詢"
Default = -1 'True
Height = 495
Left = 4080
TabIndex = 5
Top = 360
Width = 1095
End
Begin VB.CommandButton cmdDelete
Caption = "刪除"
Height = 495
Left = 6240
TabIndex = 4
Top = 360
Width = 1095
End
Begin VB.CommandButton cmdClose
Caption = "關閉"
Height = 495
Left = 7320
TabIndex = 3
Top = 360
Width = 1095
End
Begin VB.Label Label1
Caption = "名稱"
Height = 375
Left = 360
TabIndex = 7
Top = 480
Width = 1095
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 240
Top = 1440
Width = 8655
_ExtentX = 15266
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame Frame1
Caption = "查詢結果"
Height = 3975
Left = 240
TabIndex = 0
Top = 2040
Width = 8655
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "frmDelete.frx":0000
Height = 3375
Left = 360
TabIndex = 1
Top = 360
Width = 7935
_ExtentX = 13996
_ExtentY = 5953
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "frmDelete"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdClear_Click()
'清空查詢條件
txtName.Text = ""
'設置鼠標焦點
txtName.SetFocus
End Sub
Private Sub cmdQuery_Click()
Dim strSQL As String
'查詢不能為空,沒有意義
If Trim(txtName.Text) = "" Then
MsgBox "查詢姓名不能為空!", vbOKOnly + vbExclamation, "警告!"
Text1.SetFocus
Exit Sub
End If
strSQL = "Select * From product Where 名稱 like " + _
"'" + Replace(Trim(txtName.Text), "'", "''", 1) + "%'"
'設置Adodc1的連接字符串
Adodc1.ConnectionString = ConnectString
'設定Adodc1的命令類型
Adodc1.CommandType = adCmdText
'設定Adodc1的記錄源
Adodc1.RecordSource = strSQL
'刷新Adodc1
Adodc1.Refresh
End Sub
Private Sub cmdDelete_Click()
'如果有錯則轉入出錯處理部分
On Error GoTo DeleteErr
If MsgBox("您確認刪除這條記錄嗎?", vbExclamation + vbOKCancel, "產(chǎn)品刪除") = vbCancel Then
Exit Sub
End If
With Adodc1.Recordset
'如果記錄數(shù)小于等于0,則沒有記錄可以刪除
If .RecordCount <= 0 Then
MsgBox "沒有記錄可以刪除!", vbOKOnly + vbExclamation, "警告!"
Exit Sub
End If
'刪除當前記錄
.Delete
'如果刪除后記錄數(shù)小于等于0,則禁止使用Adodc1
If .RecordCount <= 0 Then
Adodc1.Enabled = False
Exit Sub
End If
'因為刪除了一條記錄,記錄移動到下一條
.MoveNext
'如果下一條是文件末尾,則移動到最后一條
If .EOF Then .MoveLast
End With
Exit Sub
DeleteErr:
'顯示出錯信息的描述
MsgBox Err.Description
End Sub
Private Sub cmdClose_Click()
'釋放窗體本身
Unload Me
End Sub
Private Sub Form_Load()
'設置Adodc1的連接字符串
'Adodc1.ConnectionString = ConnectString
'設置Adodc1的記錄源
'Adodc1.RecordSource = "Select * From product "
'將Adodc1和DataGrid1綁定,設置DataGrid1的數(shù)據(jù)源為Adodc1
'Set DataGrid1.DataSource = Adodc1
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -