📄 frselectdb.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 frSelectDB
Caption = "Select the Database using ADODC and Grid"
ClientHeight = 4710
ClientLeft = 45
ClientTop = 330
ClientWidth = 5835
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 4710
ScaleWidth = 5835
WindowState = 2 'Maximized
Begin VB.TextBox txtDSN
Height = 330
Left = 165
Locked = -1 'True
TabIndex = 4
Top = 450
Width = 4590
End
Begin VB.CommandButton doOK
Caption = "Connect"
Height = 330
Left = 4830
TabIndex = 2
Top = 465
Width = 972
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "frSelectDB.frx":0000
Height = 2385
Left = 165
TabIndex = 1
Top = 900
Width = 4575
_ExtentX = 8070
_ExtentY = 4207
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
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 = 1031
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 = 1031
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 165
Top = 3975
Visible = 0 'False
Width = 4590
_ExtentX = 8096
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 2
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 10
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 = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label1
Caption = "Selected database:"
Height = 285
Left = 165
TabIndex = 3
Top = 150
Width = 2625
End
Begin VB.Label Label2
Appearance = 0 'Flat
BackColor = &H00C0FFFF&
Caption = "For WinCC we need the DSN of the WinCC project.In the grid all DSN are shown. Select the actual project with ""R"" at the end. "
ForeColor = &H80000008&
Height = 585
Left = 165
TabIndex = 0
Top = 3330
Width = 4575
WordWrap = -1 'True
End
End
Attribute VB_Name = "frSelectDB"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim m_SER As String
'Private Sub Adodc1_RecordsetChangeComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'Debug.Print "OK"
'End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If DataGrid1.Col = 0 Then
txtDSN.Text = DataGrid1.Text
End If
End Sub
Private Sub doOK_Click()
Dim strDSN As String
strDSN = txtDSN.Text
If Len(strDSN) > 0 Then frMDIWinCCDB.CallBack (strDSN)
Unload Me
End Sub
Private Sub Form_Load()
m_SER = g_SER
Err.Clear
On Error Resume Next
doOK.Enabled = False
Dim i As Integer
For i = 1 To DataGrid1.Columns.Count - 1
DataGrid1.Columns.Remove i
Next
DataGrid1.Columns(0).DataField = "dbname"
DataGrid1.Columns(0).Caption = "Database name"
DataGrid1.Columns(0).Width = 4000
DataGrid1.HoldFields
If g_DBType = DBTYPE_RT Then
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=" & m_SER & "\WINCC"
Adodc1.RecordSource = "SELECT RTRIM(name) as dbname FROM sysdatabases WHERE name LIKE 'CC%'"
Label2.Visible = True
Else
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CC_ExternalBrowsing;Data Source=" & m_SER & "\WINCC"
Adodc1.RecordSource = "SELECT CatalogName as dbname FROM CCBrowsingCatalogs"
Label2.Visible = False
End If
Adodc1.Refresh
If Err.Number = 0 Then
If Adodc1.Recordset.RecordCount > 0 Then
Set DataGrid1.DataSource = Adodc1.Recordset
txtDSN.Text = DataGrid1.Text
doOK.Enabled = True
End If
End If
Err.Clear
On Error GoTo 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -