Include table headers from SQL query without DatabaseTool Box
조회 수: 4 (최근 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!