how to save select query string value in a variable
Show older comments
conn = database('DataBase_Name','Userid','pwd','Vendor','Microsoft SQL Server', ...
'Server','localhost','AuthType','Windows','portnumber',1433);
file_path = 'rootfolder\subfolder\images\001.jpg';
sqlquery = sprintf('select * from example_table WHERE file_name = (''%s'')', file_path);
curs = exec(conn,sqlquery);
curs = fetch(curs);
curs.Data;
close(curs);
I want to get the string from curs.Data but it is not permitting me to put into a variable.
2 Comments
dpb
on 9 Apr 2016
The code snippet above doesn't even try so what isn't "permitting" you to use a variable for the result? Errors, or simply didn't incorporate an assignment statement as above?
I don't have the Toolbox so can't check but it doesn't look like the connection above would work with literal strings as are...or are they known just placeholders for illustrative purposes not your actual code?
Usama Arshad
on 21 Apr 2016
Answers (0)
Categories
Find more on Other Formats in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!