从MATLAB调用ADO.NET [英] Invoking ADO.NET from MATLAB
问题描述
这是可能的,从MATLAB调用.NET,所以我想我会尝试使用ADO.NET连接到数据库。
It's possible to call .NET from MATLAB, so I thought I would try to use ADO.NET to connect to a database.
我似乎已经打了一个阻塞问题 - 无论何时你尝试创建一个Command对象,它抛出一个错误
I seem to have hit a blocking problem - anytime you try and create a Command object, it throws an error.
您可以自己尝试此:
>> 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.
>>
有没有人有一些见解呢?这似乎是在MATLAB的一部分,一个纯粹而简单的错误 - 也许它与恰好有一个名为连接
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".
我是不是应该认输,放弃使用MATLAB跟一个使用.NET数据库?
Should I just throw in the towel and give up on using MATLAB to talk to a database using .NET?
答(感谢的,以法齐尔的调查):MATLAB升级到版本高于2009年a
Answer (thank's to Fazil's investigations): Upgrade MATLAB to a version greater than 2009a.
推荐答案
我不能够在MATLAB重现该问题。哪个版本的MATLAB您使用的是?
I'm not able to reproduce the issue in MATLAB. Which version of MATLAB are you using?
>> version
ans =
7.9.1.705 (R2009b) Service Pack 1
>> NET.addAssembly('System.Data');
sqlconn = System.Data.SqlClient.SqlConnection();
sqlconn.State
sqlcmd = System.Data.SqlClient.SqlCommand()
ans =
Closed
sqlcmd =
System.Data.SqlClient.SqlCommand handle
Package: System.Data.SqlClient
Properties:
Connection: []
NotificationAutoEnlist: 1
Notification: []
Transaction: []
CommandText: [1x1 System.String]
CommandTimeout: 30
CommandType: [1x1 System.Data.CommandType]
DesignTimeVisible: 1
Parameters: [1x1 System.Data.SqlClient.SqlParameterCollection]
UpdatedRowSource: [1x1 System.Data.UpdateRowSource]
Site: []
Container: []
Methods, Events, Superclasses
>>
这篇关于从MATLAB调用ADO.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!