1. Trang chủ
  2. » Công Nghệ Thông Tin

Microsoft SQL Server 2005 Developer’s Guide- P30 docx

10 252 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Contents

  • Acknowledgments

  • Introduction

  • Chapter 1 The Development Environment

    • SQL Server Management Studio

      • The SQL Server Management Studio User Interface

      • SQL Server Management Studio User Interface Windows

      • SQL Server 2005 Administrative Tools

    • BI Development Studio

      • The Business Intelligence Development Studio User Interface

      • BI Development Studio User Interface Windows

    • Summary

  • Chapter 2 Developing with T-SQL

    • T-SQL Development Tools

      • SQL Server Management Studio

      • Visual Studio 2005

    • Creating Database Objects Using T-SQL DDL

      • Databases

      • Tables

      • Views

      • Synonyms

      • Stored Procedures

      • Functions

      • Triggers

      • Security

      • Storage for Searching

    • Querying and Updating with T-SQL DML

      • Select and Joins

      • Modifying Data

      • Error Handling

    • Summary

  • Chapter 3 Developing CLR Database Objects

    • Understanding CLR and SQL Server 2005 Database Engine

      • CLR Architecture

      • Enabling CLR Support

      • CLR Database Object Components

    • Creating CLR Database Objects

      • CLR Stored Procedures

      • User-Defined Functions

      • Triggers

      • User-Defined Types

      • Aggregates

    • Debugging CLR Database Objects

      • .NET Database Object Security

      • Managing CLR Database Objects

    • Summary

  • Chapter 4 SQL Server Service Broker

    • SQL Server Service Broker Architecture

      • Messages

      • Queues

      • Contracts

      • Services

      • Dialogs

    • Developing SQL Service Broker Applications

      • SQL Server Service Broker DDL and DML

      • T-SQL DDL

      • T-SQL DML

      • Enabling SQL Server Broker

      • Using Queues

      • Sample SQL Server Service Broker Application

    • SQL Server Service Broker Activation

    • Dialog Security

    • System Views

    • Summary

  • Chapter 5 Developing with Notification Services

    • Notification Services Overview

      • Events

      • Subscriptions

      • Notifications

    • Developing Notification Services Applications

      • Defining the Application

      • Compiling the Application

      • Building the Notification Subscription Management Application

      • Adding Custom Components

    • Notification Services Application Sample

      • Creating the ICF File

      • Defining the ADF File

      • Building the Notification Services Application

    • Updating Notification Services Applications

    • Building a .NET Subscription/Event Application

      • Listing Subscriptions

      • Adding Subscriptions

      • Deleting Subscriptions

      • Firing the Data Event Using .NET

      • Firing the Data Event Using T-SQL

    • Summary

  • Chapter 6 Developing Database Applications with ADO.NET

    • The ADO.NET Architecture

    • ADO.NET Namespaces

    • .NET Data Providers

      • Namespaces for the .NET Data Providers

      • Core Classes for the .NET Data Providers

    • Core Classes in the ADO.NET System.Data Namespace

      • DataSet

      • DataTable

      • DataColumn

      • DataRow

      • DataView

      • DataViewManager

      • DataRelation

      • Constraint

      • ForeignKeyConstraint

      • UniqueConstraint

      • DataException

    • Using the .NET Framework Data Provider for SQL Server

      • Adding the System.Data.SqlClient Namespace

    • Using the SqlConnection Object

      • The .NET Framework Data Provider for SQL Server Connection String Keywords

      • Opening a Trusted Connection

      • Using Connection Pooling

    • Using the SqlCommand Object

      • Executing Dynamic SQL Statements

      • Executing Parameterized SQL Statements

      • Executing Stored Procedures with Return Values

      • Executing Transactions

    • Using the SqlDependency Object

    • Using the SqlDataReader Object

      • Retrieving a Fast Forward–Only Result Set

      • Reading Schema-Only Information

      • Asynchronous Support

      • Multiple Active Result Sets (MARS)

      • Retrieving BLOB Data

    • Using the SqlDataAdapter Object

      • Populating the DataSet

      • Using the CommandBuilder Class

    • Summary

  • Chapter 7 Developing with XML

    • The XML Data Type

      • Data Validation Using an XSD Schema

    • XQuery Support

      • Querying Element Data

    • XML Data Type Methods

      • Exist(XQuery)

      • Modify(XML DML)

      • Query(XQuery)

      • Value(XQuery, [node ref])

    • XML Indexes

      • Primary XML Indexes

      • Secondary XML Indexes

    • Using the For XML Clause

      • For XML Raw

      • For XML Auto

      • For XML Explicit

      • Type Mode

      • FOR XML Path

      • Nested FOR XML Queries

      • Inline XSD Schema Generation

    • OPENXML

    • XML Bulk Load

    • Native HTTP SOAP Access

      • Creating SOAP Endpoints

      • Using SOAP Endpoints

    • Summary

  • Chapter 8 Developing Database Applications with ADO

    • An Overview of OLE DB

    • OLE DB Architecture Overview

    • ADO (ActiveX Data Objects)

    • OLE DB and ADO Files

    • ADO Architecture

      • An Overview of Using ADO

    • Adding the ADO Reference to Visual Basic

    • Using ADO Objects with Visual Basic

      • Connecting to SQL Server

      • Retrieving Data with the ADO Recordset

      • Executing Dynamic SQL with the ADO Connection Object

      • Modifying Data with ADO

      • Executing Stored Procedures with Command Objects

      • Error Handling

    • Advanced Database Functions Using ADO

      • Batch Updates

      • Using Transactions

    • Summary

  • Chapter 9 Reporting Services

    • Reporting Services Architecture

      • Reporting Services Components

      • Installing Reporting Services

    • Report Server

      • Report Server Processors

      • Report Server Extensions

    • Report Manager

    • Reporting Services Configuration and Management Tools

      • Reporting Services Configuration Tool

      • Report Server Command-Prompt Utilities

    • Report Authoring Tools

      • Report Designer

      • Report Model Designer

      • Report Builder

    • Programmability

      • Using URL Access in a Window Form

      • Integrating Reporting Services Using SOAP

      • Extensions

      • RDL

    • Accessing Reports

      • Using URL Access

      • URL Access Through a Form POST Method

    • Report Authoring

      • Development Stages

      • Creating a Reporting Services Report

      • Deploying a Reporting Services Report

      • Running a Reporting Services Report

    • Summary

  • Chapter 10 SQL Server Integration Services

    • An Overview of SQL Server Integration Services

      • Data Transformation Pipeline (DTP)

      • Data Transformation Runtime (DTR)

    • Creating Packages

      • Using the SSIS Import and Export Wizard

      • Using the SSIS Designer

      • Using Breakpoints

      • Using Checkpoints

      • Using Transactions

      • Package Security

    • Deploying Packages

      • Creating Configurations

      • Using the Package Deployment Utility

    • Programming with the SQL Server Integration Services APIs

    • Summary

  • Chapter 11 Developing BI Applications with ADOMD.NET

    • Analysis Services Overview

      • XML for Analysis

      • Analysis Management Objects (AMO) Overview

      • ADOMD.NET Overview

      • AMO Hierarchy

      • ADOMD.NET Object Model

    • Building a BI Application with ADOMD.NET

      • Adding a Reference for ADOMD.NET

      • Using the AdomdConnection Object

      • Using the AdomdCommand Object

      • Using the AdomdDataAdapter Object

      • Using the CubeDef Object

    • Summary

  • Chapter 12 Developing with SMO

    • Using SMO

      • Adding SMO Objects to Visual Studio

      • Creating the Server Object

      • Using SMO Properties

      • SMO Property Collections

    • SMO Hierarchy

    • Building the SMO Sample Application

      • Creating the Server Object

      • Listing the Registered SQL Systems

      • Connecting to the Selected SQL Server System

      • Listing Databases

      • Listing Tables

      • Listing Columns

      • Retrieving Column Attributes

      • Creating Databases

      • Transferring Tables

      • Showing T-SQL Script for Tables

      • SMO Error Handling

    • Summary

  • Chapter 13 Using sqlcmd

    • sqlcmd Components

      • Command Shell

      • Command-Line Parameters

      • sqlcmd Extended Commands

      • sqlcmd Variables

    • Developing sqlcmd Scripts

      • Developing sqlcmd Scripts with Query Editor

      • Using sqlcmd Variables

      • Using sqlcmd Script Nesting

      • Using sqlcmd Variables and T-SQL Statements

    • Summary

  • Appendix: SQL Profiler

    • Starting SQL Profiler

    • Starting, Pausing, and Stopping a Trace

    • Replaying a Trace

    • Showplan Events

  • Index

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J

    • L

    • M

    • N

    • O

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X

Nội dung

Chapter 8: Developing Database Applications with ADO 269 either the connection string must use the DRIVER keyword to make a DSN-less connection or the ODBC Driver Manager must prompt the user for the DSN to make a connection to SQL Server. In this example, the DRIVER keyword isn’t used and the value of adPromptComplete is specified in the Prompt property. This allows the ODBC Driver Manager to prompt the user to select an existing ODBC data source. After the user has responded to the ODBC Driver Manager prompt, the cn Connection object’s Open method connects to SQL Server. The Connection object’s Open method takes three optional parameters: ᭤ The fi rst optional parameter accepts a string that contains an OLE DB connection string. This parameter performs exactly the same function as the Connection object’s ConnectionString property, and you can use this parameter as an alternative to setting the ConnectionString property. ᭤ The second optional parameter accepts a String variable that contains a valid login ID for the target data source. ᭤ The third optional parameter accepts a String variable that can contain the password for the target data source. TIP While both OLE DB connection strings and the second and third parameters of the Open method let you specify login information, don’t use both at the same time. Because you normally need to use the OLE DB connection string to supply the name of the OLE DB provide anyway, supplying the login information as a part of the OLE DB connection string is usually simpler. Constant Description adPromptNever The ODBC Driver Manager can only use the information provided by the connection string to make a connection. If sufficient information is not supplied, the connection fails. adPromptAlways The ODBC Driver Manager always displays the ODBC Administrator to prompt for connection information. adPromptComplete The ODBC driver determines if all the required connection information has been supplied in the connection string. If all the required information is present, the connection is made without further prompting. If any of the required information is missing, the ODBC Administrator prompts the user for the missing information. adPromptCompleteRequired This option behaves like adPromptComplete, except any prompts containing information that has already been supplied are disabled. Table 8-3 ADO MSDASQL Prompt Constants 270 Microsoft SQL Server 2005 Developer’s Guide In this example, there’s no other processing, so the Close method ends the connection. Opening a DSN-less Connection with the OLE DB Provider for ODBC The previous example illustrated how to establish a SQL Server connection using the MSDASQL provider and an existing DSN. Instances occur when your application may need to make an ODBC-based connection, however, without being able to rely on a DSN being preconfigured. Luckily, the MSDASQL OLE DB provider also supports using DSN-less connections. Using a DSN-less connection removes the requirement for an existing data source. The following code illustrates how to use the ADO Connection object and the MSDASQL provider to make a DSN-less connection to SQL Server: Private Sub DSNlessConnect _ (sServer As String, sLoginID As String, sPassword As String) Dim cn As New ADODB.Connection ' DSNless Connection using the OLE DB provider for ODBC – MSDASSQL cn.ConnectionString = "DRIVER=SQL Server" & _ ";SERVER=" & sServer & _ ";UID=" & sLoginID & _ ";PWD=" & sPassword & _ ";DATABASE=AdventureWorks" cn.Open cn.Close End Sub Creating a new ADO Connection object named cn is the first action that takes place in this code example. Next, the ConnectionString property of the cn Connection object is assigned a connection string. As you might expect, because this connection string is intended to establish a DSN-less connection, it’s quite a bit different than the connection string presented in the preceding example. Because the PROVIDER keyword isn’t used, the MSDASQL provider for ODBC is used as the default. As you might guess, the DSN keyword isn’t needed to establish a DSN-less connection. Instead, the DRIVER keyword has the value of “SQL Server” to indicate the SQL Server ODBC driver should be used. NOTE Optionally, the value used by the DRIVER keyword can be enclosed in {}, as in {SQL Server}, but this isn’t a requirement. Chapter 8: Developing Database Applications with ADO 271 In addition to specifying the ODBC driver to be used, a DSN-less ODBC connection string must also indicate the server and database to be used. These values are supplied by the SERVER and DATABASE keywords. Finally, the UID and PWD keywords, described in Table 8-1, supply the required SQL Server login information. After setting the ConnectionString property with a DSN-less ODBC connection string, the Connection object’s Open method starts a connection to the SQL Server system. Then the Connection object’s Close method ends the connection. Opening a Connection with the OLE DB Provider for SQL Server The OLE DB provider for ODBC is primarily intended to enable ADO applications to access ODBC-compliant databases when no native OLE DB provider is available. While ODBC is certainly the established database access standard and is supported by virtually all popular databases, that’s not the case with OLE DB, which is a newer technology. The SQL Server 2000 OLE DB provider is supplied in sqloledb.dll. Using the OLE DB provider for SQL Server is similar to using the OLE DB provider for ODBC. Because the OLE DB provider for SQL Server doesn’t use ODBC, there’s no requirement for using a data source or an existing ODBC driver. However, you do need to specify the name of the OLE DB provider. The following example illustrates how to make a connection to SQL Server using the ADO Connection object and the OLE DB provider for SQL Server: Private Sub SQLOLEDBConnect _ (sServer As String, sLoginID As String, sPassword As String) Dim cn As New ADODB.Connection ' Connect using the OLE DB provider for SQL Server – SQLOLEDB cn.ConnectionString = "PROVIDER=SQLOLEDB" & _ ";SERVER=" & sServer & _ ";UID=" & sLoginID & _ ";PWD=" & sPassword & _ ";DATABASE=AdventureWorks" cn.Open cn.Close End Sub As in the previous examples, an instance of the ADO Connection object is created. Then the ConnectionString property of the ADO Connection object is assigned an 272 Microsoft SQL Server 2005 Developer’s Guide OLE DB connection string. This connection string uses the PROVIDER keyword to specify the SQLOLEDB provider is used. Specifying the PROVIDER keyword is required to use the OLE DB provider for SQL Server. If you omit this keyword, the provider defaults to the value of MSDASQL (the OLE DB provider for ODBC). In addition, the SERVER and DATABASE keywords are also required. The SERVER keyword specifies the name of the SQL Server system that will be connected to, and the DATABASE keyword identifies the database to be used. The UID and PWD keywords provide the authentication values required to log in to SQL Server if you are connecting using mixed security. If you are connecting using NT Authentication, the UID and PWD keywords are ignored, as the login will use your Windows NT user name and password. Table 8-4 lists all the provider-specific keywords provided by Microsoft’s OLE DB Provider for SQL Server. TIP As the preceding listing demonstrates, you can freely mix the provider-specific connection string keywords with the generic OLE DB connection string keywords in the connection string. Keyword Description TRUSTED_CONNECTION Uses a value of YES or NO to indicate where a value of YES indicates Windows NT authentication is to be used and a value of NO indicates mixed or SQL Server authentication should be used. CURRENT LANGUAGE Specifies the SQL Server language name to be used for this connection. NETWORK ADDRESS Specifies the SQL Server network address. NETWORK LIBRARY Specifies the network library DLL to be used. The value used by this keyword should not include the path of the .dll file extension. USE PROCEDURE FOR PREPARE Uses a value of YES or NO to indicate whether SQL Server should create temporary stored procedures for each prepared command. AUTO TRANSLATE Uses a value of TRUE or FALSE, where FALSE prevents automatic ANSI/ multibyte character conversions. The default value of TRUE automatically converts the data transferred between the SQL server and the client. PACKET SIZE Used to alter the network packet size. Accepts values from 512 to 32767. If no value is specified, a default packet size of 4096 is used. APPLICATION NAME Identifies the current application. WORKSTATION ID Identifies the client workstation. Table 8-4 Connection String Keyword for the OLE DB Provider for SQL Server Chapter 8: Developing Database Applications with ADO 273 After setting the ConnectionString property, the Open method starts the connection. Once the connection has been established, other database access can be performed. In this example, there’s no additional work, so the connection is closed using the Close method. TIP If you are connecting to a named instance of SQL Server 2005, you need to use the named instance name in conjunction with the SERVER keyword. For instance, to connect to a named instance other than the default instance, you would use the following format with the SERVER keyword: SERVER=computername\instancename. And to connect to the instance named TestServer on the computer named teca4, for example, you would use the following form of the SERVER keyword: SERVER=teca4\TestServer. Opening a Trusted Connection using the OLE DB Provider for SQL Server The preceding example illustrated how to establish a SQL Server connection using the SQLOLEDB Provider and SQL Server Security (aka mixed security). However, using NT Security, also known as Integrated Security, provides for a more secure connection because the same values used for the client’s Windows login are also used for SQL Server authentication—there’s no need to specify the user ID or the password from the application. In addition, Integrated Security can make administration easier by eliminating the need to create a set of SQL Server login IDs that are separate from the Windows NT/2000 User IDs. The following example illustrates how to make a trusted connection to SQL Server using the ADO Connection object and the OLE DB provider for SQL Server: Private Sub SQLOLEDBTrustedConnect _ (sServer As String, sLoginID As String, sPassword As String, _ bIntegratedSecurity As Boolean) Dim cn As New ADODB.Connection ' Connect using the SQLOLEDB provider cn.ConnectionString = "PROVIDER=SQLOLEDB" & _ ";SERVER=" & sServer & _ ";DATABASE=AdventureWorks" ' Use the Trusted_Connection keyword for integrated security If bIntegratedSecurity = True Then cn.ConnectionString = cn.ConnectionString _ & ";TRUSTED_CONNECTION=YES" Else ' Otherwise supply the LoginID and Password cn.ConnectionString = cn.ConnectionString & ";UID=" _ 274 Microsoft SQL Server 2005 Developer’s Guide & sLoginID & ";PWD=" & sPassword End If cn.Open cn.Close End Sub In the beginning of this subroutine, you can see where the server name, login ID, and password are passed in the subroutine as String values. In addition, the bIntegratedSecurity Boolean variable is used to indicate whether the SQL Server connection should be made using Integrated Security or SQL Server Security. A value of True indicates Integrated Security is to be used, while a value of False indicates the connection will use SQL Server Security. Next, an instance of the ADO Connection object is created and the ConnectionString property is assigned. As in the previous example, the connection string uses the PROVIDER keyword to specify the SQLOLEDB provider, and the DATABASE keyword should set AdventureWorks as the default database. Then the bIntegratedSecurity variable is tested for a value of True. If the bIntegratedSecurity variable is true, then Integrated Security is be used and the TRUSTED_CONNECTION=YES keyword is appended to the connection string. Otherwise, SQL Server Security is to be used, and the UID and PWD keywords are used to provide the SQL Server authentication information. After the ConnectionString has been set up, the ADO Connection object’s Open method is used to connect to SQL Server. In this example, after the connection has been established, it is immediately closed using the Connection object’s Close method. Open a Connection Using the Connection Object’s Properties All the previous examples have illustrated connecting to SQL Server using values supplied via the Connection object’s ConnectionString property. While providing server and database connection information is certainly a requirement to establish an ADO connection to SQL Server, using the ConnectionString property is not. You can also provide all the required connection information using the ADO Connection object’s Extended Properties. Unlike standard ADO object properties that can be viewed using the Object Browser, Extended Properties access provider-specific information that isn’t explicitly available in the standard ADO Connection object. The following example illustrates how to set up a SQL Server connection using the ADO Connection object’s extended properties: Private Sub SQLOLEDBPropertiesConnect _ (sServer As String, sLoginID As String, sPassword As String, _ bIntegratedSecurity As Boolean) Chapter 8: Developing Database Applications with ADO 275 Dim cn As New ADODB.Connection ' Specify the OLE DB provider cn.Provider = "sqloledb" ' Set the extended connection properties cn.Properties("Data Source").Value = sServer cn.Properties("Initial Catalog").Value = "AdventureWorks" ' Check for Integrated security If bIntegratedSecurity = True Then cn.Properties("Integrated Security").Value = "SSPI" Else cn.Properties("User ID").Value = sLoginID cn.Properties("Password").Value = sPassword End If cn.Open cn.Close End Sub String variables containing the server name, login ID, and password are passed in to the beginning of this subroutine, followed by the bIntegratedSecurity Boolean variable, which indicates whether Integrated Security will be used. Like the previous example, a value of True indicates Integrated Security is to be used, while a value of False indicates the connection will use SQL Server security. Next, an instance of the ADO Connection object is created and its Provider property is set to sqloledb, the name of the SQL Server OLE DB provider. After the Provider property is set, then the specific connection values are assigned to the Connection object’s Extended Properties. Each Extended Property is located in the Properties collection by using its name. For instance, the Data Source property is identified using the “Data Source” string, and its value is set to the name of the SQL Server instance to which the application intends to connect. Next the Initial Catalog property is assigned the name of the AdventureWorks database, which causes AdventureWorks to be used as the default database. TIP While you can’t see the available extended properties using the Object Browser, you can see them in the Debugger by adding an instance of the Connection object to the Watch List, and then expanding the Properties collection. Each Extended Property is listed as Item n (where n uniquely numbers each property). And as you might expect, the Name property contains the Extended Properties’ name, while the Value property contains its value. 276 Microsoft SQL Server 2005 Developer’s Guide Then the bIntegratedSecurity variable is tested for a value of True. If the bIntegratedSecurity variable is True, then the Integrated Security property is set to a value of Security Support Provider Interface (SSPI), to specify Windows NT Authentication. Otherwise, the User ID and Password connection properties are assigned values and SQL Server Security is used for the connection authentication. After the Connection object’s Extended Properties have been assigned connection values, the Open method is used to connect to SQL Server. The connection is then closed using the Connection object’s Close method. Connecting to SQL Server Using a UDL File A Universal Data Link (UDL) file is the OLE DB equivalent to an ODBC File DSN. Like an ODBC File DSN, a UDL file stores OLE DB connection information, such as the provider, server, database username, password, and other connection options you can use to establish an ADO connection. One of the advantages to using a UDL file is that an administrator or developer can centrally create the UDL file, which can then be distributed to all networked clients along with the application. From an application developer’s standpoint, using a UDL file to connect to SQL Server is similar to using the standard OLE DB connection string. The following example illustrates how you can use an existing UDL file to connect to SQL Server. Private Sub SQLOLEDBUDLConnect() Dim cn As New ADODB.Connection ' Connect using the OLE DB Provider for SQL Server – SQLOLEDB cn.ConnectionString = "FILE NAME=" & App.Path & \\udlSample.udl cn.Open cn.Close End Sub First an instance of the ADO Connection object is created, and then the ConnectionString property of the Connection object is assigned a string consisting of the FILE NAME= keyword, followed by the path and name of the UDL that contains the SQL Server connection information. In this example, the udlsample.udl file is located in the same directory as the VB database application. If the application were located in the c:\DBApp directory, the resolved connection string would then appear as follows: "FILE NAME=C:\DBApp\udlsample.udl" After the Connection object’s ConnectionString property has been assigned the FILE NAME keyword and the path to the existing UDL, the Open method is used to Chapter 8: Developing Database Applications with ADO 277 connect to SQL Server. The connection is then closed using the Connection object’s Close method. Connecting to SQL Server Using the Data Link Dialog Just as it’s possible to cause the ODBC driver to prompt the user for any required connection parameters at run time, it’s also possible to prompt for the required OLE DB connection values at run time. However, nothing that’s inherently a part of either OLE DB or ADO lets you prompt for the connection attributes. Instead, OLE DB connection properties are captured at run time using the DataLink dialog, which is a part of the OLE DB Service object. Adding a Reference to the OLE DB Service Object Before you can use the Data Link dialog box from your Visual Basic application, you must add a reference to the Microsoft OLE DB Service Component 1.0 Type Library, as well as a reference to the Microsoft ActiveX Data Objects 2.8 Library. To add a reference to Visual Basic, select the References option from Visual Basic’s Project menu. The References dialog box shown in Figure 8-7 is then displayed. When the References dialog box is first displayed, scroll through the list of references until you see the Microsoft OLE DB Service 1.0 Type Library. Figure 8-7 Adding the OLE DB Service Component Type Library 278 Microsoft SQL Server 2005 Developer’s Guide Clicking the check box immediately in front of the name, and then clicking the OK button adds a reference to the OLE DB Service Library to the current VB project. After a reference to the OLE DB Service Library has been added to your project, you can use Visual Basic’s Object Browser to view the object’s properties and methods, as shown in Figure 8-8. After a reference to the OLE DB Service Component 1.0 Type Library is added to VB, you can then create an instance of the Data Link object in your application that displays the OLE DB connection prompts to the end user. The following code listing shows the code to display the Data Link dialog box: Private Sub SQLOLEDBPromptConnect(cn As ADODB.Connection) Dim dl As New MSDASC.DataLinks ' Display the Data Link Dialog Set cn = dl.PromptNew On Error Resume Next Figure 8-8 Viewing the DataLink object in the Object Browser . SQL Server 2000 OLE DB provider is supplied in sqloledb.dll. Using the OLE DB provider for SQL Server is similar to using the OLE DB provider for ODBC. Because the OLE DB provider for SQL Server. keyword: SERVER= teca4TestServer. Opening a Trusted Connection using the OLE DB Provider for SQL Server The preceding example illustrated how to establish a SQL Server connection using the SQLOLEDB. illustrates how to make a connection to SQL Server using the ADO Connection object and the OLE DB provider for SQL Server: Private Sub SQLOLEDBConnect _ (sServer As String, sLoginID As String,

Ngày đăng: 05/07/2014, 05:20