frmConnData.frm
上传用户:yexiandon
上传日期:2022-07-12
资源大小:895k
文件大小:8k
- VERSION 5.00
- Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
- Begin VB.Form frmConnData
- BorderStyle = 3 'Fixed Dialog
- Caption = "打开帐套"
- ClientHeight = 2295
- ClientLeft = 2760
- ClientTop = 3750
- ClientWidth = 4440
- Icon = "frmConnData.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2295
- ScaleWidth = 4440
- ShowInTaskbar = 0 'False
- StartUpPosition = 2 '屏幕中心
- Begin VB.CommandButton cmdConnect
- Caption = "连接"
- Height = 300
- Left = 3360
- TabIndex = 7
- Top = 120
- Width = 900
- End
- Begin VB.CommandButton cmdDel
- Caption = "删除"
- Enabled = 0 'False
- Height = 300
- Left = 3360
- TabIndex = 11
- Top = 1200
- Width = 900
- End
- Begin VB.CommandButton cmdNew
- Caption = "新建"
- Enabled = 0 'False
- Height = 300
- Left = 3360
- TabIndex = 9
- Top = 840
- Width = 900
- End
- Begin VB.TextBox txtSa
- Height = 270
- IMEMode = 3 'DISABLE
- Left = 1080
- TabIndex = 3
- Top = 435
- Width = 2115
- End
- Begin VB.TextBox txtServer
- Height = 270
- Left = 1080
- TabIndex = 1
- Top = 120
- Width = 2115
- End
- Begin VB.TextBox txtSaPass
- Height = 270
- IMEMode = 3 'DISABLE
- Left = 1080
- PasswordChar = "*"
- TabIndex = 5
- Top = 750
- Width = 2115
- End
- Begin VB.CommandButton cmdClose
- Caption = "关闭"
- Height = 300
- Left = 3360
- TabIndex = 10
- Top = 1560
- Width = 900
- End
- Begin VB.CommandButton cmdOpen
- Caption = "打开"
- Enabled = 0 'False
- Height = 300
- Left = 3360
- TabIndex = 8
- Top = 480
- Width = 900
- End
- Begin MSFlexGridLib.MSFlexGrid GD1
- Height = 1065
- Left = 120
- TabIndex = 6
- Top = 1080
- Width = 3135
- _ExtentX = 5530
- _ExtentY = 1879
- _Version = 393216
- Rows = 3
- Cols = 3
- BackColorBkg = 12632256
- AllowBigSelection= 0 'False
- FocusRect = 0
- ScrollBars = 2
- SelectionMode = 1
- Appearance = 0
- FormatString = "序号|数据库|帐套名称"
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "登陆名(&U):"
- Height = 180
- Index = 2
- Left = 120
- TabIndex = 2
- Tag = "密码(&P):"
- Top = 450
- Width = 900
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "服务器(&S):"
- Height = 180
- Index = 0
- Left = 120
- TabIndex = 0
- Tag = "用户名(&U):"
- Top = 135
- Width = 900
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "密 码(&P):"
- Height = 180
- Index = 1
- Left = 120
- TabIndex = 4
- Tag = "密码(&P):"
- Top = 765
- Width = 900
- End
- End
- Attribute VB_Name = "frmConnData"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '****************************************************************************
- '人人为我,我为人人
- '枕善居收藏整理
- '发布日期:2008/01/21
- '描 述:汽车维修管理系统SQL2000版
- '网 站:http://www.Mndsoft.com/ (VB6源码博客)
- '网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
- 'e-mail :Mndsoft@163.com
- 'e-mail :Mndsoft@126.com
- 'OICQ :88382850
- ' 如果您有新的好的代码别忘记给枕善居哦!
- '****************************************************************************
- Option Explicit
- Private datPrimaryRS As ADODB.Recordset
- Private Sub cmdClose_Click()
- Unload Me
- End Sub
- Private Sub cmdConnect_Click()
- If g_Conn.State = 1 Then g_Conn.Close
- On Error GoTo err_Connect
- If txtServer <> "" And txtSa <> "" Then
- Screen.MousePointer = vbHourglass
- If ConnectToDatabase(txtServer, "Master", txtSa, txtSaPass) Then
- cmdOpen.Enabled = True
- cmdNew.Enabled = True
- cmdDel.Enabled = True
- Dim rcds As New ADODB.Recordset
- Dim TbExist As Boolean
- Set rcds = g_Conn.OpenSchema(adSchemaTables)
- TbExist = False
- Do While Not rcds.EOF
- If rcds("TABLE_NAME") = "t_Account_qxzt" And rcds("TABLE_TYPE") = "TABLE" Then
- TbExist = True
- Exit Do
- End If
- rcds.MoveNext
- Loop
- Set rcds = Nothing
- If Not TbExist Then g_Conn.Execute ("CREATE TABLE t_Account_qxzt(ID INT IDENTITY,DBNM VARCHAR(20) NOT NULL,ZTNM VARCHAR(30) NOT NULL)")
- LoadGD
- g_Conn.Close
- End If
- Screen.MousePointer = vbDefault
- Else
- MsgBox "服务器和登陆名不能为空!"
- cmdOpen.Enabled = False
- cmdNew.Enabled = False
- cmdDel.Enabled = False
- End If
- err_Connect:
- If Err.Number <> 0 Then MsgBox Err.Description
- End Sub
- Private Sub cmdDel_Click()
- Dim cnn As New Connection
- cnn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;" & _
- "User ID=" & txtSa & ";Initial Catalog=master;Data Source=" & txtServer & ";pwd=" & txtSaPass
- cnn.Open
- cnn.Execute ("delete from t_Account_qxzt where DBNM='" & GD1.TextMatrix(GD1.Row, 1) & "'")
- cnn.Close
- cmdConnect_Click
- End Sub
- Private Sub cmdNew_Click()
- frmNewDB.Show vbModal
- cmdConnect_Click
- End Sub
- Private Sub cmdOpen_Click()
- On Err GoTo ERR_OPEN
- If ConnectToDatabase(txtServer, GD1.TextMatrix(GD1.Row, 1), txtSa, txtSaPass) Then
- g_DBname = GD1.TextMatrix(GD1.Row, 1)
- g_ACCname = GD1.TextMatrix(GD1.Row, 2)
- frmLogin.txtAccount = g_ACCname
- WritePrivateProfileString "Connect", "ServerName", txtServer.Text, App.Path & "ConfigConfig.ini"
- WritePrivateProfileString "Connect", "ServerUID", txtSa.Text, App.Path & "ConfigConfig.ini"
- WritePrivateProfileString "Connect", "ServerUPass", txtSaPass.Text, App.Path & "ConfigConfig.ini"
- WritePrivateProfileString "Connect", "DBname", g_DBname, App.Path & "ConfigConfig.ini"
- WritePrivateProfileString "Connect", "ACCname", g_ACCname, App.Path & "ConfigConfig.ini"
- g_Conn.Close
- Unload Me
- End If
- Exit Sub
- ERR_OPEN:
- MsgBox Err.Description
- End Sub
- Private Sub Form_Load()
- With GD1
- .ColWidth(0) = 450
- .ColWidth(1) = 1000
- .ColWidth(2) = 1530
- End With
- txtServer = ReadIniFile(App.Path & "ConfigConfig.ini", "Connect", "ServerName")
- txtSa = ReadIniFile(App.Path & "ConfigConfig.ini", "Connect", "ServerUID")
- txtSaPass = ReadIniFile(App.Path & "ConfigConfig.ini", "Connect", "ServerUPass")
- If txtServer <> "" And txtSa <> "" Then cmdConnect_Click
- End Sub
- Private Sub LoadGD()
- Dim rsr, rsc, r, c As Integer
- Dim Rs As New ADODB.Recordset
- With GD1
- .Clear
- Rs.Open "select ID AS 序号,DBNM AS 数据库,ZTNM AS 帐套名称 from t_Account_qxzt", g_CnStr, adOpenKeyset, adLockReadOnly
- rsr = Rs.RecordCount
- rsc = Rs.Fields.Count
- .Cols = rsc
- For c = 0 To rsc - 1
- .TextMatrix(0, c) = Rs.Fields(c).Name
- Next
- If rsr > 0 Then
- If rsr > .Rows - 1 Then .Rows = rsr + 1
- Rs.MoveFirst
- For r = 1 To rsr
- For c = 0 To rsc - 1
- .TextMatrix(r, c) = Rs(c)
- Next
- Rs.MoveNext
- Next
- End If
- Rs.Close
- End With
- Set Rs = Nothing
- End Sub
- Private Sub GD1_DblClick()
- cmdOpen_Click
- End Sub