Jump to content
Sign in to follow this  
knifeman

deal with the problems in SQL commands

Recommended Posts

Hi, I am coming back! Haaaaa, happy.gif

I meet a new problem that is SQL operation. I have written some independence programs which fit to my destinations, and now I want to use two input parameters

Share this post


Link to post
Share on other sites
Hi, I am coming back! Haaaaa, happy.gif

I meet a new problem that is SQL operation. I have written some independence programs which fit to my destinations, and now I want to use two input parameters

Share this post


Link to post
Share on other sites

Also, I want to double-check what datatypes you are expecting in the database before I give any advice. Could you describe the tablename, fieldname, and field type?

Thanks

Share this post


Link to post
Share on other sites

Merry charismas every friends!

The question I post some days ago have been solved, and I am too busy to browse the Internet so make you spend your time and interesting on my topic, thank you. Thank you very much! Your hot passion make the winner become warm and hopeful!

The point to solve the problem is to initial the loop structure. With the method the program could tell apart which is the content this loop and which is the last loop, otherwise it read every strings and do not analysis what is the useful part, and this is my question

Share this post


Link to post
Share on other sites
I want to ask that what you do if you use LabVIEW to operate the DataBase for advance operations such as select tables with different objects(3 phase voltages, 3 phase currents,etc.) and different items (different time and different range)?

I'm not sure what your problem is now, but here's a suggestion for what I believe is an equivalent piece of code:

post-1431-1167084855.png?width=400

You should also make sure that you format the date-time string in a format which the database can recognize.

Anyway, my suggestion for working with databases is not to refer to the tables directly, but to create functions (VIs) which will perform tasks and seperate you from the database structure. For example, you could have a VI called "Save Results". It will accept a typedef cluster or an array with the relevant results and will internally call whatever tables and queries it needs to perform its function.

If you are asking about how to generate SQL code which will interact with several tables or have conditions, you should search for SQL tutorials or books.

Share this post


Link to post
Share on other sites

yen:

I have read your code and thank you for you give me another method to create the SQL commands, thank you!

My problem focused on one point that how the program meet users

Share this post


Link to post
Share on other sites
yen:

I have read your code and thank you for you give me another method to create the SQL commands, thank you!

My problem focused on one point that how the program meet users' different needs. I have written an edition and try to rewrite and make it slimmer and more intelligent, but the process is so complex and full of flections!

I found that NI offered us the only port to access the database! We can write some commands through it but I have not found the way to build a SQL program. What is your opinion? And could you tell me what function you have implemented about the database technology in LabVIEW (the concept is enough and do not need the concrete code)?

The reason why nobody has the ultimate 'SQL' library is that SQL is not completely standardized across different databases. The syntax for SQL for an Oracle database is different than the syntax for a MySQL or SQL Server database. Each database has slightly different versions based on their own optimizations, legacy codes, etc. This makes it really difficult to create more than an interface to the database which is what the Database Connectivity Toolkit is. Once you've connected to the database (which thankfully has been standardized across the vendors through interfaces such as ADO), you are on your own to create SQL commands that get you useful info. The other part that makes it difficult to create a 'Universal' database library is that each database implementation is unique. Different constraints, different table structures, custom stored procedures, etc make it pretty difficult to build a really flexible toolkit. Basically, this is where design patterns come into play. If you can get YOUR organization to adopt different design patterns, you can start building reusable SQL queries that will be flexible for YOUR solutions.

Its no easy task and often takes many iterations but it can be useful in the long run. Good luck!

Share this post


Link to post
Share on other sites
I found that NI offered us the only port to access the database! We can write some commands through it but I have not found the way to build a SQL program. What is your opinion? And could you tell me what function you have implemented about the database technology in LabVIEW (the concept is enough and do not need the concrete code)?

Unless you have the DB toolkit, NI did not offer you anything - All the tools for accessing DBs from LV go directly to the providers. Most of them use ADO (ActiveX or .net) which is a part of Windows and I have seen some that use DLLs, but in any case, NI did not write anything there.

What NI did write (and sells) is the DB connectivity toolkit, which is a set of VIs which include some basic functions (create table, insert into table, build a parameterized query, etc.), but this toolkit only includes a small fraction of the things you can do with DBs. The main work it does is in parsing all the data types so that you can wire anything into the VIs.

I do use the DB toolkit and I have found that once I've added some VIs (like Update Table or wrapper VIs which make the selection of data easier) that it was good enough.

If you want an example of an application I wrote, here's one - a weighing system at a compost site (yes, I know, it stinks :angry: ) where drivers come with their trucks and get weighed going in and coming out and everything is in a DB (the lists of drivers, trucks, clients, orders, shipments, etc.).

So an example of a function would be a VI which returns a list of truck names and IDs (each object in a DB should have a unique identifier). This allows putting the list of trucks and IDs in a ring control and when the truck is selected the value of the ring is the ID, and that can be used in the queries.

Note that behind the scenes the VI can be going to several tables, but all the caller knows is that the VI will return a 1D array of strings (the names) and a 1D array of I32 (the IDs).

The same would apply to any other list in the program.

Another example is a VI which returns the details about a truck - it recieves a truck ID and returns a typedef cluster of data. Again, the VI could internally be doing a lot of stuff, but the caller doesn't care.e

Share this post


Link to post
Share on other sites

Happy new year everybody! Because of the Taiwan earthquake my best wish is late for 8 days. Wish you all healthy and happy every day in 2007.

My project is getting more and more close to the end. I have finished the SQL part and now I want to grant the remote PCs to access to local database. In LabVIEW, the DataBase

Share this post


Link to post
Share on other sites
I want to grant the remote PCs to access to local database. In LabVIEW, the DataBase's kernel is connection, so the first thing I must face to is how to create the connection between different PCs.

Do you have a database management system which supports networked databases (like SQL Server or MySQL)?

I believe that Access does not support this, so if your DB is an Access DB (or Jet, to be more accurate), you might have a problem.

Anyway, to connect to a DB, you need a connection string. You can create this string by going to the Windows Control Panel > Administrative Tools > ODBC Data Sources and creating a UDL or DSN file pointing to your DB. The file should have the connection string inside it or you can point Windows directly to the file.

If you have an Access DB, you might be able to provide access to it by placing it on a network drive.

In any case, this is not an LV issue, so I suggest you do some searching on ADO, ODBC and connection strings to see how to set up your connection.

Share this post


Link to post
Share on other sites
I believe that Access does not support this, so if your DB is an Access DB (or Jet, to be more accurate), you might have a problem.

hmm ... Access does support this in a *certain* way, but I would not use it, because the Jet module creates a local copy of the *.mdb file for each query, which means, that you get a real huge network load with increasing file sizes and if your network gets to slow, you have a good chahce to loose the integrity of your data => if you have multiple clients, use a DBS

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.