Results 1 to 4 of 4

Thread: Query 2 server from vb application

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2011
    Posts
    32

    Query 2 server from vb application

    I have to have my VB 2015 application query data from Server1 which is accessed over a VPN connection that is always online and then insert the results into a Table on Server2 which is a local server.

    I have the query working in SQl Management studio with the VPN DB setup as a linked server, but I am not sure how to accomplish the same thing from my VB application?

    Thank you,

    Steve

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Query 2 server from vb application

    Let me ask this: why would it be any different? Any SQL you run in SQL Management Studio can be run from VB. Once you have your VPN connection open, after your linked server connection has been established... select your data and insert it. You should only even need to setup the linked server connection just once...so after that, you should only need to make sure your VPN connection is open before trying to use the linked server. But the fact that you're calling the query from VB code doesn't change the rules. If it makes you feel better, put it in a stored proc, and simply call that...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2011
    Posts
    32

    Re: Query 2 server from vb application

    Quote Originally Posted by techgnome View Post
    Let me ask this: why would it be any different? Any SQL you run in SQL Management Studio can be run from VB. Once you have your VPN connection open, after your linked server connection has been established... select your data and insert it. You should only even need to setup the linked server connection just once...so after that, you should only need to make sure your VPN connection is open before trying to use the linked server. But the fact that you're calling the query from VB code doesn't change the rules. If it makes you feel better, put it in a stored proc, and simply call that...

    -tg

    Oh, I always thought that the linked server was just for the connection from my computer, I didn't realize that once its set, it stays there for everyone from all computers.

    Thank you,

    Steve

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Query 2 server from vb application

    Well... maybe... It's tied to the database... So it's in the database where you originated it from. So if you made it from your local database to the remote database, it's in your database. It won't exist anywhere else. That's all you asked about. You didn't mention there being other databases involved. But... that said... the linked servers should be scriptable, which means you can check to see if they exist, and if not, run the SQL script to create them... then once they are in that database, they are there.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width