Include table headers from SQL query without DatabaseTool Box
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!