Include table headers from SQL query without DatabaseTool Box

5 visualizaciones (últimos 30 días)
Dan Howard
Dan Howard el 17 de Abr. de 2018
As this is my first posting, please be patient as im still fairly new to Matlab. With the help from this forum I have found a way to use the ADODB connection string to make a connection to the SQL Database with a simple SQL query for test purposes ( without using the Database ToolBox).
connection_string = 'Provider = SQLOLEDB;Integrated Security=SSPI;Persist Security Info = False;Initial Catalogue = TESTDB;Data Source=TESTSERVER;'
conn = actxserver('ADODB.Connection');
conn.Open(connection_string);
test=conn.Execute('select * from TestTable');
table = test.GetRows();
end
The scrip above extracts every row from 'TestTable' and outputs the results into table using the GetRows ActiveX Method.
The only thing im trying to work out is on is if its possible to include the table headers? As the results are output into a table array called 'table' is there a way to include the headers from the SQL query using an ADODB method?
Is there a way to use the 'catch' 'try' error method in Matlab aswell? For ref. currently using 2015b version.
Any help would be gratefully appreciated.

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by