LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read data or value from a varaible from dabase

 
      Hi,, All..
      I'm currently having  a problem to read a variable from a SQL  Server,
      I send a query as a command then  I need to read the anwer from
      SQL.  So far I don't know how to di it.   The anwer I'm looking for will
       b bolean  (0, 1 ang char).
 
      This is what i use to sennd data,  it works OK.
 
          DB Tools Open Coneect  (Path).vi
          DB Tools Execute Query.vi
          DB Tools Free Object.vi
          DB Tools Connection.vi
 
        Does anyone has a waty how to do it?
 
        Best Regards.
        Reynnalfo Lima V.
Ing. Reynaldo Lima Villarreal
Ingenieria Electronica (I N G E L)
Reynosa, Tamps. México

Cel: +52 899 160-52-59
Email: reynaldolima@aol.com
0 Kudos
Message 1 of 13
(3,827 Views)
Here is an example that I did to read from an Access Database using SQL.

SELECT testdata,test
 FROM oven1data
WHERE test BETWEEN '10/31/2006 1:14:57 PM' AND '10/31/2006 1:23:31 PM'

it is in the form:

SELECT (table)
FROM (column)
WHERE (clause)

You can check out http://www.w3schools.com/sql/sql_select.asp for some good information and examples on SQL quiries.  There are many options you can use for retreiving data from the datbase.

In order to read the data, I use the DB Tools vi's in the following order: Open Connection, Execute Query, Fetch Requested Data, Free Object, Close connection

Kenny


Kenny

0 Kudos
Message 2 of 13
(3,813 Views)

 

 Thanks Kenny.

  I will try it.  

 I'll keep in touch

 Reynaldo Lima V.

Ing. Reynaldo Lima Villarreal
Ingenieria Electronica (I N G E L)
Reynosa, Tamps. México

Cel: +52 899 160-52-59
Email: reynaldolima@aol.com
0 Kudos
Message 3 of 13
(3,800 Views)
You can also use the "DB Tools Select Data.vi", provide the table name and the columns (database fields) you want data from. You'll get a 2D array of variants back. The rows correspond to the data sets, the columns to the fields you specified. All you have to do is convert the variants to the correct data type (using the "Database Variant to Data" function).
If you don't want all data sets, you can specify an optional clause in the "DB Tools Select Data.vi" like "WHERE id = 2" (if "id" is one of your fields).

Daniel

0 Kudos
Message 4 of 13
(3,784 Views)
 
            Hi all..
 
            Here's a copy of the code i'm writting, but can't figure out the way to do it,  This is the first time
            is use SQL, 
 
            I'm sure I'm close,
 
            Please take a look at the code.
            What I need to get from SQL Server is the value of a variable of a table to verify a previous process
            has been done    
 
            Thanks
            Rlima//
Ing. Reynaldo Lima Villarreal
Ingenieria Electronica (I N G E L)
Reynosa, Tamps. México

Cel: +52 899 160-52-59
Email: reynaldolima@aol.com
0 Kudos
Message 5 of 13
(3,769 Views)
 
            Hi all..
 
            Here's a copy of the code i'm writting, but can't figure out the way to do it,  This is the first time
            is use SQL, 
 
            I'm sure I'm close,
 
            Please take a look at the code.
            What I need to get from SQL Server is the value of a variable of a table to verify a previous process
            has been done    
 
            Thanks
            Rlima//
Ing. Reynaldo Lima Villarreal
Ingenieria Electronica (I N G E L)
Reynosa, Tamps. México

Cel: +52 899 160-52-59
Email: reynaldolima@aol.com
0 Kudos
Message 6 of 13
(3,767 Views)
You need to add a semi-colon(;) at the end of your query text.
0 Kudos
Message 7 of 13
(3,755 Views)

You are on the right trackSmiley Very Happy

Your SQL query should have seperate lines, like.

select audio_tester

from unit_status

where model = 'CCQJN2660X' and serial_num = 311200

Also, instead of using the Fetch, try using the Fetch All vi.  That will fetch all the data that you requested.

 

Let me know how it goes.

 

Kenny

0 Kudos
Message 8 of 13
(3,752 Views)
disregard this message...


Message Edited by dan_u on 01-03-2007 04:42 PM

0 Kudos
Message 9 of 13
(3,752 Views)
OK, so that's how you guys add those funny faces.  That was meant to be a semicolon inside 2 parentheses.
0 Kudos
Message 10 of 13
(3,747 Views)