sql = "select * from 用户 where 用户名='" + cmb_yhm.Text _
+ "' and 用户密码='" + Trim(txt_mm.Text) + "'"
cnn.Open strcnn
rst.Open sql, cnn, 3, adLockOptimistic
If rst.RecordCount > 0 Then
MsgBox "密码输入正确!欢迎登录!", vbOKOnly + vbInformation, "信息"
yh_login.yhqx = rst!用户权限
yh_login.yhm = rst!用户名
Unload Me
Frm_main.Show 1
Else
MsgBox "密码错误!请重新输入!", vbOKOnly + vbExclamation, "信息"
txt_mm.Text = ""
txt_mm.SetFocus
End If
End Sub
Private Sub Command2_Click()
If MsgBox("你确定要退出吗?", vbQuestion + vbOKCancel, "提示") = vbOK Then
End
End If
End Sub
Private Sub Form_Load()
cmb_qx.AddItem "管理员"
cmb_qx.AddItem "操作员"
End Sub
Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblfj.ForeColor = vbBlack
lblfj.FontUnderline = False
End Sub
Private Sub lblfj_Click()
Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim sql As String
sql = "exec sp_attach_db 'tushu'," _
+ "'" + App.Path + "\DataBase\tushu_Data.MDF'," _
+ "'" + App.Path + "\DataBase\tushu_Log.LDF'"
On Error GoTo lab
cnn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI"
cnn.BeginTrans
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdText
cmd.CommandText = sql
cmd.Execute
cnn.CommitTrans
cnn.Close
MsgBox "数据库附加成功!", vbInformation, "提示"
Exit Sub
lab:
If cnn.State = 1 Then
cnn.RollbackTrans
cnn.Close
End If
MsgBox "数据库已附加!", vbExclamation, "提示"
End Sub
Private Sub lblfj_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lblfj.ForeColor = vbBlue
lblfj.FontUnderline = True
End Sub
3.4.6 系统数据备份与恢复代码设计
①数据备份代码如下:
<< 上一页 [11] [12] [13] [14] [15] [16] 下一页