OLEDBCommand与SQLCommand [英] OLEDBCommand vs. SQLCommand

查看:91
本文介绍了OLEDBCommand与SQLCommand的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么时候使用其中一个?为什么?我无法想象当你用数据库进行通信时,你不想使用SQL语句的东西太多了 - 即使是在只读的基础上。另外还有ODBCCommand类的

- 我知道这是一个较旧的实现,并且

在.Net中没有使用,对吗?


Thanx任何澄清以及可能通过网络链接进行讨论。

-

Anil Gupte
www.keeninc.net
www.icinema.com

When does one use one or the other? And why? I cannot imagine too many
innstances where you would not want to use SQL statements when you
communicating with a database - even on a read-only basis. Plus there is
the ODBCCommand class too - I understand that is an older implementation and
is not used in .Net much, correct?

Thanx for any clarifications and perhaps web links to discussion on this.
--
Anil Gupte
www.keeninc.net
www.icinema.com

推荐答案

我可能在这里错了,但如果我有人肯定会纠正我am:


就SQL语句而言,所有三个命令都使用它们与

数据库进行通信,前缀为Command的前缀。或连接或是一个指标

它可以访问什么,而不是如何访问。话虽如此,OleDbCommand'是
用于与提供数据库的任何OLEDB进行通信,如Oracle,
Access,SQL Server,Excel等。但是SQLCommand是创建

特别是对于Microsoft的SQL Server数据库,提供了一些SQL

服务器特定功能和更好的性能。最后,对于ODBC投诉数据库(几乎所有数据库都使用)使用ODBC

。但是,ODBC

要求您在使用它之前设置DSN(数据源名称) - 或者至少它曾经使用过
- 并且效率低于使用OleDbCommands或

SQLCommands,但可能是您唯一的选择,具体取决于数据库。


这有帮助吗?


谢谢,


Seth Rowe

Anil Gupte写道:
I might be wrong here, but someone will surely correct me if I am:

As far as SQL statements go, all three commands use them to talk to the
database, the prefix before "Command" or "Connection" is an indicator
of what it can access, not how. With that said, the OleDbCommand''s are
for communicating with any OLEDB providing databases, like Oracle,
Access, SQL Server, Excel, etc. However the SQLCommand is created
especially for Microsoft''s SQL Server databases, providing some SQL
server specific features and better performance. Finally ODBC is used
for ODBC complaint databases (almost all databases are). However, ODBC
requires that you set up a DSN (data source name) before using it - or
at least it used to - and is less efficient than using OleDbCommands or
SQLCommands, but may be your only choice depending on the database.

Does that help?

Thanks,

Seth Rowe
Anil Gupte wrote:

什么时候使用一个或者其他?为什么?我无法想象当你用数据库进行通信时,你不想使用SQL语句的东西太多了 - 即使是在只读的基础上。另外还有ODBCCommand类的

- 我知道这是一个较旧的实现,并且

在.Net中没有使用,对吗?


Thanx任何澄清以及可能通过网络链接进行讨论。

-

Anil Gupte
www.keeninc.net
www.icinema.com




rowe_newsgroups ha scritto:

rowe_newsgroups ha scritto:

我可能在这里错了,但如果我有人肯定会纠正我:


就SQL语句而言,所有三个命令都使用它们来说话到

数据库,Command之前的前缀。或连接或是一个指标

它可以访问什么,而不是如何访问。话虽如此,OleDbCommand'是
用于与提供数据库的任何OLEDB进行通信,如Oracle,
Access,SQL Server,Excel等。但是SQLCommand是创建

特别是对于Microsoft的SQL Server数据库,提供了一些SQL

服务器特定功能和更好的性能。
I might be wrong here, but someone will surely correct me if I am:

As far as SQL statements go, all three commands use them to talk to the
database, the prefix before "Command" or "Connection" is an indicator
of what it can access, not how. With that said, the OleDbCommand''s are
for communicating with any OLEDB providing databases, like Oracle,
Access, SQL Server, Excel, etc. However the SQLCommand is created
especially for Microsoft''s SQL Server databases, providing some SQL
server specific features and better performance.



我一直在想这个。我一直在使用OLEDB

对抗SQL服务器而且速度很快。是否有任何原因,对于

实例,

SQLCommand发送的查询应该比通过OLEDBcommand发送的同一查询更快?
?和OLE DB

读者相比,你的SQL读取器更快吗?


我没有这种感觉。有没有人对此进行一些测试?


我认为使用OLEDB可能会带来如下优势:如果您更改底层数据库,则无需更改码。这似乎是一个巨大的b $ b b b使用它的理由。

此外,访问GUID的可能性也很重要。这是另一个巨大的原因。

实际上我不清楚为什么需要专门的连接器。如果

有一种专业化的形式,通用连接器应该是智能的

足以在连接到特定DBMS时使用专门的功能。


什么不是所有oledb方式?你们怎么想?

最后使用ODBC

I have been always wondering about that. I have been using the OLEDB
against SQL server and it is fast. Is there any reason why , for
instance,
a query sent by the SQLCommand should be faster than the same query
sent via an OLEDBcommand ? And id the sql reader faster than the OLEdb
reader ?

I do not have this feeling. Has anyone some test about that?

I think that using OLEDB may give the advantage that if you change
the underlying DB you do not have to change the code. And this seems to
be a huge
reason to use it whenever possible.
Also the possibility to access the GUIDs is fundamental. And this is
another huge reason.

Actually I am not clear why the need sort of specialized connectors. If
there is a form of a specialization a generic connector should be smart
enough to use specialized function when connected to specific DBMS.

What not make all the oledb way? What do you guys think ??
Finally ODBC is used


用于ODBC投诉数据库(几乎所有数据库都是)。但是,ODBC

要求您在使用它之前设置DSN(数据源名称) - 或者至少它曾经使用过
- 并且效率低于使用OleDbCommands或

SQLCommands,但可能是您唯一的选择,具体取决于数据库。


这有帮助吗?


谢谢,


Seth Rowe


Anil Gupte写道:
for ODBC complaint databases (almost all databases are). However, ODBC
requires that you set up a DSN (data source name) before using it - or
at least it used to - and is less efficient than using OleDbCommands or
SQLCommands, but may be your only choice depending on the database.

Does that help?

Thanks,

Seth Rowe
Anil Gupte wrote:

什么时候一个使用其中一个?为什么?我无法想象当你用数据库进行通信时,你不想使用SQL语句的东西太多了 - 即使是在只读的基础上。另外还有ODBCCommand类的

- 我知道这是一个较旧的实现,并且

在.Net中没有使用,对吗?


Thanx任何澄清以及可能通过网络链接进行讨论。

-

Anil Gupte
www.keeninc.net
www.icinema.com


就个人而言,我几乎总是使用OleDb类。这主要是因为当我写超类时我把它写成与我公司使用的所有服务器兼容

,这意味着OleDb或ODBC(而且我讨厌ODBC)。如果我们只有SQL Server数据库,我可能会更改我的

故事,但在那之前我会坚持使用Oledb。我做了一些搜索

的差异和Bill Vaughn的一篇文章说,关于COM互操作的OleDb类

现实,而SQLClient是SQL的真正本机/>
服务器版本7及以上。


希望有人会发布两者之间差异的链接。


谢谢,


Seth Rowe
pa ***** ******@libero.it 写道:
Personally, I almost always use the OleDb classes. This is mainly
because when I wrote my "superclass" I wrote it to be compatible with
all the servers my company uses, meaning either OleDb or ODBC (and I
hate ODBC). If all we had were SQL Server databases I might change my
story but until then I''ll stick with Oledb. I did a few searches for
the differences and one post from Bill Vaughn said the the OleDb class
realies on COM interop while the SQLClient is a truely native to SQL
Server versions 7 and up.

Hopefully someone will post a link to the differences between the two.

Thanks,

Seth Rowe
pa***********@libero.it wrote:

rowe_newsgroups ha scritto:
rowe_newsgroups ha scritto:

我可能在这里错了,但是如果我有人肯定会纠正我:


就SQL语句而言,所有三个命令都使用它们来交谈

数据库,Command之前的前缀或连接或是一个指标

它可以访问什么,而不是如何访问。话虽如此,OleDbCommand'是
用于与提供数据库的任何OLEDB进行通信,如Oracle,
Access,SQL Server,Excel等。但是SQLCommand是创建

特别是对于Microsoft的SQL Server数据库,提供了一些SQL

服务器特定功能和更好的性能。
I might be wrong here, but someone will surely correct me if I am:

As far as SQL statements go, all three commands use them to talk to the
database, the prefix before "Command" or "Connection" is an indicator
of what it can access, not how. With that said, the OleDbCommand''s are
for communicating with any OLEDB providing databases, like Oracle,
Access, SQL Server, Excel, etc. However the SQLCommand is created
especially for Microsoft''s SQL Server databases, providing some SQL
server specific features and better performance.



我一直在想这个。我一直在使用OLEDB

对抗SQL服务器而且速度很快。是否有任何原因,对于

实例,

SQLCommand发送的查询应该比通过OLEDBcommand发送的同一查询更快?
?和OLE DB

读者相比,你的SQL读取器更快吗?


我没有这种感觉。有没有人对此进行一些测试?


我认为使用OLEDB可能会带来如下优势:如果您更改底层数据库,则无需更改码。这似乎是一个巨大的b $ b b b使用它的理由。

此外,访问GUID的可能性也很重要。这是另一个巨大的原因。

实际上我不清楚为什么需要专门的连接器。如果

有一种专业化的形式,通用连接器应该是智能的

足以在连接到特定DBMS时使用专门的功能。


什么不是所有oledb方式?你们怎么想?


最后使用ODBC


I have been always wondering about that. I have been using the OLEDB
against SQL server and it is fast. Is there any reason why , for
instance,
a query sent by the SQLCommand should be faster than the same query
sent via an OLEDBcommand ? And id the sql reader faster than the OLEdb
reader ?

I do not have this feeling. Has anyone some test about that?

I think that using OLEDB may give the advantage that if you change
the underlying DB you do not have to change the code. And this seems to
be a huge
reason to use it whenever possible.
Also the possibility to access the GUIDs is fundamental. And this is
another huge reason.

Actually I am not clear why the need sort of specialized connectors. If
there is a form of a specialization a generic connector should be smart
enough to use specialized function when connected to specific DBMS.

What not make all the oledb way? What do you guys think ??
Finally ODBC is used


用于ODBC投诉数据库(几乎所有数据库都是)。但是,ODBC

要求您在使用它之前设置DSN(数据源名称) - 或者至少它曾经使用过
- 并且效率低于使用OleDbCommands或

SQLCommands,但可能是您唯一的选择,具体取决于数据库。


这有帮助吗?


谢谢,


Seth Rowe

Anil Gupte写道:
for ODBC complaint databases (almost all databases are). However, ODBC
requires that you set up a DSN (data source name) before using it - or
at least it used to - and is less efficient than using OleDbCommands or
SQLCommands, but may be your only choice depending on the database.

Does that help?

Thanks,

Seth Rowe
Anil Gupte wrote:

什么时候使用一个或者其他?为什么?我无法想象当你用数据库进行通信时,你不想使用SQL语句的东西太多了 - 即使是在只读的基础上。另外还有ODBCCommand类的

- 我知道这是一个较旧的实现,并且

在.Net中没有使用,对吗?

>

Thanx任何澄清以及可能的网络链接讨论此事。

-

Anil Gupte
www.keeninc.net
www.icinema.com


这篇关于OLEDBCommand与SQLCommand的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆