home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / rds.cab / vbtoadf.dob < prev    next >
Text File  |  1997-08-14  |  5KB  |  155 lines

  1. VERSION 5.00
  2. Begin VB.UserDocument VbtoADFdoc 
  3.    ClientHeight    =   3570
  4.    ClientLeft      =   45
  5.    ClientTop       =   270
  6.    ClientWidth     =   9225
  7.    HScrollSmallChange=   15
  8.    ScaleHeight     =   3570
  9.    ScaleWidth      =   9225
  10.    VScrollSmallChange=   15
  11.    Begin VB.Frame Frame2 
  12.       Caption         =   " Query Using RDSServer.DataFactory "
  13.       Height          =   3015
  14.       Left            =   120
  15.       TabIndex        =   0
  16.       Top             =   240
  17.       Width           =   8655
  18.       Begin VB.TextBox txtServer 
  19.          Height          =   375
  20.          Left            =   3600
  21.          TabIndex        =   6
  22.          Top             =   720
  23.          Width           =   4455
  24.       End
  25.       Begin VB.ListBox List1 
  26.          Height          =   2205
  27.          Left            =   240
  28.          TabIndex        =   5
  29.          Top             =   360
  30.          Width           =   1932
  31.       End
  32.       Begin VB.TextBox txtGetRecordset 
  33.          Height          =   372
  34.          Left            =   3600
  35.          TabIndex        =   3
  36.          Top             =   1680
  37.          Width           =   4452
  38.       End
  39.       Begin VB.TextBox txtConnect 
  40.          Height          =   372
  41.          Left            =   3600
  42.          TabIndex        =   2
  43.          Top             =   1200
  44.          Width           =   4452
  45.       End
  46.       Begin VB.CommandButton cmdGetRecordset 
  47.          Caption         =   "&Run"
  48.          Height          =   372
  49.          Left            =   3600
  50.          TabIndex        =   1
  51.          Top             =   2280
  52.          Width           =   1572
  53.       End
  54.       Begin VB.Label Label4 
  55.          Caption         =   "Enter valid Server, Connect, and Query properties and click Run"
  56.          Height          =   255
  57.          Left            =   3600
  58.          TabIndex        =   9
  59.          Top             =   360
  60.          Width           =   4815
  61.       End
  62.       Begin VB.Label Label3 
  63.          Caption         =   "Query:"
  64.          BeginProperty Font 
  65.             Name            =   "MS Sans Serif"
  66.             Size            =   8.25
  67.             Charset         =   0
  68.             Weight          =   700
  69.             Underline       =   0   'False
  70.             Italic          =   0   'False
  71.             Strikethrough   =   0   'False
  72.          EndProperty
  73.          Height          =   255
  74.          Left            =   2640
  75.          TabIndex        =   8
  76.          Top             =   1800
  77.          Width           =   735
  78.       End
  79.       Begin VB.Label Label2 
  80.          Caption         =   "Server:"
  81.          BeginProperty Font 
  82.             Name            =   "MS Sans Serif"
  83.             Size            =   8.25
  84.             Charset         =   0
  85.             Weight          =   700
  86.             Underline       =   0   'False
  87.             Italic          =   0   'False
  88.             Strikethrough   =   0   'False
  89.          EndProperty
  90.          Height          =   255
  91.          Left            =   2640
  92.          TabIndex        =   7
  93.          Top             =   840
  94.          Width           =   735
  95.       End
  96.       Begin VB.Label Label1 
  97.          Caption         =   "Connect:"
  98.          BeginProperty Font 
  99.             Name            =   "MS Sans Serif"
  100.             Size            =   8.25
  101.             Charset         =   0
  102.             Weight          =   700
  103.             Underline       =   0   'False
  104.             Italic          =   0   'False
  105.             Strikethrough   =   0   'False
  106.          EndProperty
  107.          Height          =   255
  108.          Left            =   2640
  109.          TabIndex        =   4
  110.          Top             =   1320
  111.          Width           =   735
  112.       End
  113.    End
  114. End
  115. Attribute VB_Name = "VbtoADFdoc"
  116. Attribute VB_GlobalNameSpace = False
  117. Attribute VB_Creatable = True
  118. Attribute VB_PredeclaredId = False
  119. Attribute VB_Exposed = True
  120. Dim ads As New RDS.DataSpace
  121. Dim adf As Object
  122.  
  123. Private Sub UserDocument_Initialize()
  124.   txtServer.Text = "http://"
  125.   txtConnect.Text = "Dsn=AdvWorks;Uid=;Pwd=;"
  126.   txtGetRecordset.Text = "Select ProductName from Products"
  127. End Sub
  128.  
  129. Private Sub cmdGetRecordset_Click()
  130.   On Error GoTo cmdGetRecordset_Click
  131.   If Trim(txtServer.Text) = "http://" And Len(Trim(txtServer.Text)) = 7 Then
  132.     MsgBox "Please enter a valid server name."
  133.   Else
  134.     MousePointer = vbHourglass
  135.  
  136.     'Create AdvancedDataFactory using CreateObject Method of Advanced Data Space
  137.     Set adf = ads.CreateObject("RDSServer.DataFactory", CStr(txtServer.Text))
  138.     
  139.     'Populate ListBox with Recordset
  140.     Dim objADORs As Object
  141.     Set objADORs = adf.Query(CStr(txtConnect.Text), CStr(txtGetRecordset.Text))
  142.     List1.Clear
  143.     While Not objADORs.EOF
  144.       List1.AddItem objADORs(0).Value
  145.       objADORs.MoveNext
  146.     Wend
  147.     MousePointer = vbNormal
  148.   End If
  149.   Exit Sub
  150. cmdGetRecordset_Click:
  151.   MousePointer = vbNormal
  152.   MsgBox Err.Description
  153. End Sub
  154.  
  155.