linetodata.frm

来自「vb+mapx小型地图系统」· FRM 代码 · 共 279 行

FRM
279
字号
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form linetodata 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "绑定数据集"
   ClientHeight    =   5625
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3690
   Icon            =   "linetodata.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5625
   ScaleWidth      =   3690
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   2880
      Top             =   3840
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command4 
      Caption         =   "删除"
      Height          =   375
      Left            =   2640
      TabIndex        =   8
      Top             =   2280
      Width           =   855
   End
   Begin VB.ListBox List1 
      Height          =   2040
      Left            =   1080
      TabIndex        =   7
      Top             =   2280
      Width           =   1455
   End
   Begin VB.CommandButton Command3 
      Caption         =   "返回"
      Height          =   375
      Left            =   2640
      TabIndex        =   6
      Top             =   4920
      Width           =   855
   End
   Begin VB.CommandButton Command2 
      Caption         =   "确定"
      Height          =   375
      Left            =   120
      TabIndex        =   5
      Top             =   4920
      Width           =   855
   End
   Begin VB.CommandButton Command1 
      Caption         =   "...."
      Height          =   375
      Left            =   2760
      TabIndex        =   4
      Top             =   360
      Width           =   375
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1080
      TabIndex        =   3
      Text            =   "Text1"
      Top             =   360
      Width           =   1575
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      Left            =   1080
      TabIndex        =   0
      Text            =   "Combo1"
      Top             =   1200
      Width           =   1575
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   1080
      Top             =   3720
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   661
      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         =   "Adodc1"
      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.Label Label3 
      Caption         =   "全部字段:"
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   2160
      Width           =   975
   End
   Begin VB.Label Label2 
      Caption         =   "数据源:"
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   360
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "帮定对象:"
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   1200
      Width           =   975
   End
End
Attribute VB_Name = "linetodata"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sfile As String
Dim str As String

Dim i As Integer
Dim fieds As New MapXLib.Fields

Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Dim combostr As String



Private Sub Combo1_Click()
Set rs = Nothing
Set cnn = Nothing
List1.Clear


datahasLayer = Combo1.ListIndex



combostr = Combo1.Text

str = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Text1.Text & ";user id=admin;" & " password=;Persist Security Info=False"
cnn.ConnectionString = str
cnn.CursorLocation = adUseClient
cnn.Open

   

  Set rs = cnn.Execute("Select * From " & combostr)
  rs.MoveLast

For i = 0 To rs.Fields.Count - 1


 List1.AddItem rs.Fields(i).Name
 
 fieds.Add rs.Fields(i).Name, rs.Fields(i).Name, miAggregationAuto
 
 Next i

 rs.Close
 cnn.Close
 

End Sub

Private Sub Command1_Click()

With CommonDialog1
                .DialogTitle = "打开数据源"
                .Filter = "MicroSoft Office Access(*.mdb)|*.mdb"
                .ShowOpen
                If Len(.filename) = 0 Then
                    Exit Sub
End If
sfile = .filename
End With
Text1.Text = sfile
Combo1.Visible = True

End Sub

Private Sub Command2_Click()

'On Error GoTo err


str = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Text1.Text & ";user id=admin;" & " password=;Persist Security Info=False"
With Adodc1
   .ConnectionString = str
   .RecordSource = "Select * From " & combostr
   .Refresh
   .Recordset.MoveLast


End With
 Set ds1 = mainform.Map1.DataSets.Add(miDataSetADO, Adodc1.Recordset, combostr, "Name_yy", , combostr, fieds)
MsgBox "绑定成功", 64, "信息提示"
mainform.mundatasearch.Enabled = True
isdatahas = True
Adodc1.Recordset.Close
Unload Me

'err:

'MsgBox "数据有错误", 64, "信息提示"
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Command4_Click()
Dim j As Integer

If List1.ListIndex = -1 Then
MsgBox "请先选一个数据集", 64, "信息提示"
Else

j = List1.ListIndex
List1.RemoveItem j
fieds.Remove j
End If

End Sub

Private Sub Form_Load()

Combo1.Visible = False

Dim data_layer As MapXLib.layer
For Each data_layer In mainform.Map1.Layers

        Combo1.AddItem data_layer.Name
        Next
        Combo1.Text = mainform.Map1.Layers(1).Name
        
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?