Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - Running a Distributed Query with Visual Ba...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Running a Distributed Query with Visual Basic Using ADO
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2006-07-05

    Table of Contents:
  • Running a Distributed Query with Visual Basic Using ADO
  • Adding a linked server to the SQL 2000 server
  • Running a query against the Linked Server
  • Probing the Linked Server

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Running a Distributed Query with Visual Basic Using ADO - Probing the Linked Server


    (Page 4 of 4 )

    Collected in the click event of the Command3 button are four of the stored procedures that can be run on the SQL Server 2000. They show some of the details about the Linked Server, its table, columns, Primary Keys, and so forth. This is not a complete list, but please refer to the SQL 2000 Server Book-on-line for other related stored procedures.

    Private Sub Command3_Click()
    'Choose the option and send the strsql to the sqlst Procedure
    If Option1.Value = True Then strsql = "Exec sp_helplinkedsrvlogin" 
    Call sqlst (strsql) ElseIf Option2.Value = True Then strsql =
    "Exec sp_tables_ex 'GoodLink'" Call sqlst (strsql) ElseIf Option3.Value =
    True Then strsql = "Exec sp_Columns_ex GoodLink, 'Employees' " Call sqlst
    (strsql) ElseIf Option4.Value = True Then strsql = "Exec sp_primarykeys
    GoodLink, 'Order Details' " Call sqlst (strsql) End If End Sub Sub sqlst (ByVal strg As String) 'sqlst passed the string to the recordset open() method as 'an argument. Otherwise it is similar to the Command2 code 'described earlier. Dim connstr As String Dim strsql As String connstr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" _ & "Persist Security Info=False; Initial Catalog=Northwind;" _ & "Data Source=XPHTEK" If adors.State = 1 Then adors.Close End If adors.CursorLocation = adUseClient adocon.Open connstr adors.Open strg, connstr, adOpenStatic, adLockReadOnly Set DataGrid1.DataSource = adors adocon.Close End Sub

    In order to find the information choose one of the radio buttons. For the screen shot shown here, the "Examine the Linked Server" button  was clicked after choosing "Find all tables in the linked server." The grid is filled with the retrieved information as shown in the screen shot.

    Summary

    ADO objects provide a convenient way to add and manage a linked server on a SQL Server, and allow you to run distributed queries. Only some of the stored procedures were examined, but you may find several more in the Book On Line. While the Openquery() method returned the columns in their natural order, the four-part syntax returned the columns in alphabetical order. In the tutorial presented, Windows authentication for the SQL Server and remote authentication for an unsecured database were used. If these are different in your situation, changes must be made for the code.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · The trend in the future is for increased distibuted data as it adds to agility....
     

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek