Currently I'm working on a program which I would like to fit to a few computers. I query some hardware IDs (disk, mainboard and CPU) with WMI according to this site:
https://msdn.microsoft.com/en-us/library/aa390423(v=vs.85).aspx
As SQL is used there, is it possible not only to recieve data via SELECT but to change data via a UPDATE query? If so, this attempt to create a "copy-protected program" would fail, right?
The WMI uses the WQL language which is only a small subset of the ANSI SQL. The WQL language doesn't supports the UPDATE or INSERT statements. Also if you want update some property value this depends if the WMI property/class is writable, finally depending of what you want accomplish you must use the IWbemClassObject.Put or the IWbemServices.PutInstance method.
Related
I was wondering how i could easily read and write to Microsoft access files.
I have to be able to create and write to it with 2 variables(depending on inputs during the program) and then if this person repeats this more than 3 times it must only store the last the three inputs they do but all this must be done in access.
Dan, the answer depends a little on your situation, and the technology you are using. In general, I would look at using ADO. You would reference ADO in your application, and then connect to the Access DB using a connection string.
Which technology are you using to try and connect?
Check out this article and let me know if it helps:
http://support.microsoft.com/kb/168336
I m doing a software in c++ that permit to access to some rdbms with qt library.
The software is only for pc.
The software need to know the name of rdbms and version beacuse the program needs to choose some sql query to execute. Is there any way to retrieve thisdata in any rdbms?
Is there any way to retrieve thisdata in any rdbms?
This is specific to each RDBMS - for example, in Oracle, you can do
select *
from v$version;
but in other RDBMS this view does not exist.
Some possible approaches:
You need to define connect parameters somewhere anyways. Even they are often RDBMS-specific, so you could simply add another parameter like SQLFlavor=Oracle or SQLFlavor=MySQL and then use the value of SQLFlavor in your code to determine which SQL statement to use
You can use some heuristics to find out the RDBMS. For example, query the v$version view - if it does not exist, you will get an error and you know that it is not Oracle and you can continue with the next try (like SELECT VERSION() to see if it is MySQL). Otherwise, you can use the result to find out the concrete Oracle version.
I'm locally running an instance of Oracle 11gR2 for testing. I'm connecting to it with OLEDB using VC++. I use CCommand and I'm able to select, update, insert and delete from my tables.
What I can't do right now is execute stored procedures.
It is a simple stored procedure that inserts a row to my table. I can run it from SQL Plus without a hitch. However, when I come to execute it from my code, it doesn't work. I get a 80040e14 error.
It's pretty straightforward, but here is the line anyway.
hr = cmd.Open(session, "exec get_item_count");
Any ideas?
EXEC is SQL*Plus syntax. It is not valid outside SQL*Plus (and a variety of PL/SQL GUIs that implement many of the features SQL*Plus provides).
You probably want something like this (using ODBC syntax)
hr = cmd.Open(session, "{call get_item_count}");
or this (using Oracle syntax)
hr = cmd.Open(session, "begin get_item_count; end;");
If you use the Oracle syntax, the same syntax will work both in SQL*Plus and from your application. SQL*Plus does not understand ODBC syntax. However, other OLE DB providers will support ODBC syntax so ODBC syntax is portable across different database engines.
Additionally, if you have a PL/SQL object that retrieves an item count, that should be a stored function not a stored procedure. You say that the procedure is inserting a row into your table, which is something that a procedure should do and a function should not, but the name of the object get_item_count doesn't seem to match your description of what it is doing.
I have public interface which allows people to interact with the database by typing in sql commands. However, I do not want them to change the database in any way (and if possible, not access certain tables). As I understand though, SQLite has no concept of users, so how do I accomplish this?
If within the query there are no application defined sql functions, which indirectly modifies the database(e.g: SELECT eval('DELETE FROM t1') FROM t2; ), then use sqlite3_stmt_readonly to determine whether the prepared sql statement writes the database, otherwise you can try to open an other, read_only, database connection handler(SQLITE_OPEN_READONLY) which will be used for read_only access.
Copy the "master" database file first and open that :-) No, really, this is a serious suggestion.
Otherwise, depending on how SQLite is accessed, the SQLITE_OPEN_READONLY flag that can be passed to sqlite3_open_v2. This applies to the entire connection -- and all transactions on that connection.
Another option is to limit the SQL entry, but this is very very hard to do correctly and thus I don't recommend this route.
Happy coding.
I am trying to build an application for Windows XP 64bit which is able to detect drives of a particular model in the system, and if they are not initialized & formatted perform these processes.
I would also like to be able to query and set the partition information(including the volume label).
I have started putting together code using DeviceIoControl, but I have not been able to figure out how to set/get partition/volume labels or format drives with the method, I have got SMART access working.
Is there any other method that is any easier to use?
Zac
Sounds like you are looking for Disk Management Control Codes.
If I were doing this I would use my own code only to detect things. I would do the partitioning and formatting through diskpart and/or format commands instead. diskpart accepts file argument with a script to execute.