It’s possible to call .NET from MATLAB, so I thought I would try to use ADO.NET to connect to a database.
I seem to have hit a blocking problem – anytime you try and create a Command object, it throws an error.
You can try this yourself:
>> NET.addAssembly('System.Data');
>> sqlconn = System.Data.SqlClient.SqlConnection();
>> sqlconn.State
ans =
Closed
>> % So far, so good
>> sqlcmd = System.Data.SqlClient.SqlCommand();
??? Error using ==> System.Data.SqlClient.SqlCommand
'Connection' is already defined as a property.
>>
Does anyone have some insight into this? It seems like a pure and simple bug on MATLAB’s part – maybe it happens with every .NET class that happens to have a property called “Connection”.
Should I just throw in the towel and give up on using MATLAB to talk to a database using .NET?
Answer (thank’s to Fazil’s investigations): Upgrade MATLAB to a version greater than 2009a.
I’m not able to reproduce the issue in MATLAB. Which version of MATLAB are you using?