-
Sep 12th, 2017, 01:36 PM
#1
Thread Starter
Member
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
-
Sep 12th, 2017, 02:07 PM
#2
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
-
Sep 12th, 2017, 02:17 PM
#3
Thread Starter
Member
Re: Query 2 server from vb application
Originally Posted by techgnome
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
-
Sep 12th, 2017, 04:06 PM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|