03-15-2010 05:53 PM
I would like to get the serial number of a part just being tested. This info is stored in a SQL database. The info I got from the database administrator is as follows.
Host: partdb.mlp.abcd.comPort: 1433
Database Name: part
Read Only User Id: yyyy
Password: xxxx
Example query for engine serial number between certain time period: select *from tdheader h inner join tdstage son h.s_sno = s.s_snowhere h.testCellNo = 5and h.endTime between '3-15-2010 7:00:00' and '3-15-2010 8:00:00'
How do I query the database from LabVIEW? Thanks.
Ian
03-15-2010 05:58 PM
Example query for engine serial number between certain time period:
select *
from tdheader h inner join tdstage s
on h.s_sno = s.s_sno
where h.testCellNo = 5
and h.endTime between '3-15-2010 7:00:00' and '3-15-2010 8:00:00'
03-15-2010 06:32 PM
03-15-2010 08:28 PM
03-15-2010 10:56 PM
The specified query should return all columns from the specified join. This would be the columns from the table "tdheader" and the table "tdstage". The toolkit will return a 2D array of variants, so you need to typecast to the appropriate datatype. My guess is that you want a 2D array of strings. Then you need to pick off the column that contains the serial number.
You could limit the select statement to return the column you're interested in by replacing the "*" with the column name. You'll still get a 2D array of variants, but it should only have one column.
As for a SQL tutorial, just use Google.
03-16-2010 07:29 AM
Thanks for your help.
But first thing first, I did not find any example to access a database via a host, a port (1433, TCP/IP) and a database name? All examples I can find has a file name on a hard disk (eg, C:\NI\Demos\dB\connection.udl). Can someone share an example LabVIEW code? Thanks.
03-16-2010 08:45 AM
03-16-2010 08:51 AM
-Hunter
03-16-2010 08:54 AM
Hueter wrote:
In order to connect to a database in LabVIEW you need to create a Universal Data Link (UDL) file.
That's a somewhat misleading statement. That's one of the ways you can connect. As I indicated, and as the Database Connectivity documentation indicates, you can use a UDL, a DSN, or a connection string.
03-19-2010 02:19 PM
I used a DSN (http://forums.ni.com/ni/board/message?board.id=170&message.id=253700&query.id=3657466#M253700
)and it worked.
Many thanks to all.
Ian