C#access数据库查询返回值

C#access数据库查询返回值,第1张

int c=odc.ExecuteNonQuery()//这里出错了(这里适用的sql语句为 Update,InsertSelect是不适用的)

正确为:

int c=odc.ExecuteScalar()//

一.

实现结果:在一个数据库某个用户下编写一个存储过程,在存储过程中使用dblink连接另一个数据库,从此数据库中的一个用户下取数,然后插入当前的数据库中的一个表中。

二.

实现方法步骤:

1.

创建存储过程

2.

在存储过程中先创建database

link

3.

创建成功

4.

从另一个数据库取出数据插入到当前数据库中

5.

任务完成

三.

创建dblink的方法:

1.

create

public

database

link

dblink

connect

to

totalplant

identified

by

totalplant

using

'(description

=

(address_list

=

(address

=

(protocol

=

tcp)(host

=

localhost)(port

=

1521))

)

(connect_data

=

(service_name

=

prd.gdc)

)

)'

语法解释:create

public

database

link

dblink名字(自己随便起)

connect

to

用户名

identified

by

密码

using

'(description

=

(address_list

=

(address

=

(protocol

=

tcp)(host

=

要连接的数据库所在服务器的ip地址)(port

=

1521))

)

(connect_data

=

(service_name

=

要连接的数据库的在本地的服务名(即要连接的数据库的sid))

)

)'

2.

如果创建private的dblink

create

database

link

dblink

connect

to

totalplant

identified

by

totalplant

using

'(description

=

(address_list

=

(address

=

(protocol

=

tcp)(host

=

localhost)(port

=

1521))

)

(connect_data

=

(service_name

=

prd.gdc)

)

)'


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/6778066.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-28
下一篇2023-03-28

发表评论

登录后才能评论

评论列表(0条)

    保存