LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connect to Linked SQL Server

I am having an issue connecting to a "linked server" in SQL.

 

I can use the UDL file to connect to a server, Server A, and read/query all the tables I want from that database/server.  The issue I have is that I am unable to see the "linked server"'s (Server B) tables (or database) in the UDL file, so I cannot query the tables.

 

Server B is actually at a vendors side, and replicates the data over to our server once a day.  In Studio Manager, I am able to query the linked server database and tables just fine.  But I cannot seem to find where to make the database from the linked server availible in the UDL file.  Maybe I do not need to use the UDL, but that is the way I have done it so far.

 

I have tried to use the "DB Tools Select Data.vi", and the SELECT statement was "SELECT * FROM SERVERB.DATABASE.dBo.TABLE, but it does not return anything.  I was using the UDL file to connect to the ServerA, which makes me select a default database, I am not sure if this is part of the issue.

 

 

Kenny

Message 1 of 6
(2,938 Views)

Hello Kenny,

 

I think there are a few things you can try to solve this issue. First, check the UDL file contents. If it is making you connect to a default database, perhaps you can modify the UDL to make this default the 'B' database you are trying to access. 

 

Also, look into how exactly you are connecting to each server. In Management Studio, are they both using UDL? Is it the same UDL file or separate files? I think the best thing to do would be to have two separate UDL files, one for each server. Then in your LabVIEW application, you can connect to each one and query data as needed. Then you can use one to access server B directly, without first connecting to A. You may have to contact the vendor to obtain a UDL file for this server, or at least the information necessary to create one.

 

If this doesn't work, it may have to do with the data you are trying to retrieve, is it a binary or bitmap file?

 

Hope that this information helps. 

Best Regards,

Roel F.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(2,889 Views)
Does the query return an error? Or just no data? How was the link established?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 6
(2,852 Views)

No data is returned, no error is reported either.

 

I have been connecting using the UDL file to Server A, but I cannot figure out how to get to the linked server through the UDl file.

Kenny

0 Kudos
Message 4 of 6
(2,806 Views)
A couple thoughts:

First, the fact that you didn't get an error says that the link is good and that your syntax for referring to the linked tables is good. There simply isn't any data that matches the set criteria specified in your query.

Second , if you want to connect to Server B directly you will need a connection string for that database that is distinct from the connection string in the UDL you are using to connect to Server A.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 6
(2,799 Views)
BTW, what kind of databases are these and are they located on the same computer?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 6
(2,798 Views)