📄 connectsde.frm
字号:
VERSION 5.00
Begin VB.Form frmConnectSDE
BorderStyle = 3 'Fixed Dialog
Caption = "Connect SDE Layer"
ClientHeight = 4605
ClientLeft = 5505
ClientTop = 4410
ClientWidth = 8625
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 4605
ScaleWidth = 8625
ShowInTaskbar = 0 'False
Begin VB.Frame Frame2
Caption = "2. Select SDE Layer from Database"
Height = 3855
Left = 3960
TabIndex = 14
Top = 600
Width = 4515
Begin VB.ListBox lstLayers
Height = 3180
Left = 240
TabIndex = 5
Top = 420
Width = 4035
End
End
Begin VB.Frame Frame1
Caption = "1. Enter SDE Server Information"
Height = 2415
Left = 180
TabIndex = 9
Top = 660
Width = 3675
Begin VB.CommandButton cmdConnect
Caption = "Co&nnect"
Height = 315
Left = 1320
TabIndex = 4
Top = 1980
Width = 1515
End
Begin VB.TextBox txtServer
Height = 285
Left = 1080
TabIndex = 0
Top = 360
Width = 2220
End
Begin VB.TextBox txtDatabase
Height = 285
Left = 1080
TabIndex = 1
Top = 780
Width = 2220
End
Begin VB.TextBox txtUser
Height = 285
Left = 1080
TabIndex = 2
Top = 1200
Width = 2220
End
Begin VB.TextBox txtPassword
Height = 285
IMEMode = 3 'DISABLE
Left = 1080
PasswordChar = "*"
TabIndex = 3
Top = 1620
Width = 2220
End
Begin VB.Label lblServer
Alignment = 1 'Right Justify
Caption = "Server:"
Height = 195
Left = 420
TabIndex = 13
Top = 420
Width = 555
End
Begin VB.Label lblDatabase
Alignment = 1 'Right Justify
Appearance = 0 'Flat
Caption = "Database:"
ForeColor = &H80000008&
Height = 195
Left = 120
TabIndex = 12
Top = 840
Width = 855
End
Begin VB.Label lblUser
Alignment = 1 'Right Justify
Appearance = 0 'Flat
Caption = "User:"
ForeColor = &H80000008&
Height = 195
Left = 480
TabIndex = 11
Top = 1200
Width = 495
End
Begin VB.Label lblPassword
Alignment = 1 'Right Justify
Appearance = 0 'Flat
Caption = "Password:"
ForeColor = &H80000008&
Height = 195
Left = 120
TabIndex = 10
Top = 1680
Width = 855
End
End
Begin VB.CommandButton cmdApply
Caption = "&Apply"
Height = 375
Left = 2520
TabIndex = 8
Top = 3840
Width = 975
End
Begin VB.CommandButton cmdCancel
Caption = "&Cancel"
Default = -1 'True
Height = 375
Left = 1440
TabIndex = 7
Top = 3840
Width = 975
End
Begin VB.CommandButton cmdOK
Caption = "&OK"
Height = 375
Left = 360
TabIndex = 6
Top = 3840
Width = 975
End
Begin VB.Label Label1
Caption = "To add an SDE layer to the map, first establish the connection to a SDE server and then select an SDE layer from the list."
Height = 375
Left = 180
TabIndex = 15
Top = 120
Width = 5895
End
End
Attribute VB_Name = "frmConnectSDE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private SDEConn As New mapobjects2.DataConnection
Private Sub applyConnect()
Screen.MousePointer = vbHourglass
'If Connection was successful, update control enabling.
'If not, then produce a helpful error message from either
'the MO DataConnection, or the extended error received from
'the SDE database.
If SDECon.Connect Then
Dim gs As Object
lstLayers.Clear
For Each gs In SDECon.GeoDatasets
lstLayers.AddItem gs.Name
Next gs
cmdApply.Enabled = True
cmdOK.Enabled = True
cmdConnect.Enabled = False
txtDatabase.Enabled = False
txtServer.Enabled = False
txtPassword.Enabled = False
txtUser.Enabled = False
bSDEConnected = True
Screen.MousePointer = vbDefault
' MsgBox "Connected successfully", vbInformation, "SDE Connection"
Else
Screen.MousePointer = vbDefault
MsgBox ConnectErrorMsg(SDECon.ConnectError), vbCritical, "SDE Connection Error"
cmdConnect.Enabled = True 'Allow to try again
bSDEConnected = False
End If
End Sub
Private Sub cmdApply_Click()
'Pass the SDE connection back to the calling procedure.
Call frmMain.addSDElayer(SDEConn)
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Call frmMain.addSDElayer(SDEConn)
Unload Me
End Sub
Private Sub cmdConnect_Click()
SDECon.Server = txtServer.text
SDECon.Database = txtDatabase.text
SDECon.User = txtUser.text
SDECon.Password = txtPassword.text
cmdApply.Enabled = False
cmdOK.Enabled = False
Call applyConnect
End Sub
Private Sub Form_Load()
cmdApply.Enabled = False
cmdOK.Enabled = False
'If there is already an SDE connection, use it instead
'of requiring that the user provide this info again (...and again,...)
If bSDEConnected Then
txtDatabase = SDECon.Database
txtServer = SDECon.Server
txtPassword = SDECon.Password
txtUser = SDECon.User
applyConnect
Else
txtDatabase = "esri_sde"
txtServer = "drfinlay"
txtPassword = "sde_user"
txtUser = "sde_user"
End If
End Sub
Private Sub lstLayers_DblClick()
' cmdApply_Click
End Sub
'
'Highlight text boxes when they get the focus.
'
Private Sub txtDatabase_GotFocus()
HiliteText txtDatabase
End Sub
Private Sub txtPassword_GotFocus()
HiliteText txtPassword
End Sub
Private Sub txtServer_GotFocus()
HiliteText txtServer
End Sub
Private Sub txtUser_GotFocus()
HiliteText txtUser
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -