首先是添加ORACLE和SQL Server的引用(reference),ORACLE用的是它自带的类库
Imports
System.Data.SqlClient
Imports
Oracle.DataAccess.Client
在app.config里面设好connection string,具体如下:
<
appSettings
>
<
add key
=
“
SQLServerConnectionString
“
value
=
“
Data Source=MAPPA03C;Initial Catalog=LVSS;Integrated Security=True
“
/>
<
add key
=
“
OracleConnectionString
“
value
=
“
DATA SOURCE=lvnet;PASSWORD=lvss;PERSIST SECURITY INFO=False;USER ID=LVSS
“
/>
</
appSettings
>
然后便是在获得SQL Server和Oracle连接.
‘
——————————————————————–
‘
Function: GetSQLServerConn()
‘
Description: Implement the connection to SQL server database with the connection string in app.config
‘
Input:
‘
Remark:
‘
——————————————————————–
Public
Shared
Function GetSQLServerConn()
Function GetSQLServerConn() As SqlConnection
Dim conn As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings(“SQLServerConnectionString“))
conn.Open()
Return conn
End Function
‘
——————————————————————–
‘
Function: GetOracleConn()
‘
Description: Implement the connection to oracle database with the connection string in app.config
‘
Input:
‘
Remark:
‘
——————————————————————–
Public
Shared
Function GetOracleConn()
Function GetOracleConn() As OracleConnection
Dim conn As New OracleConnection(System.Configuration.ConfigurationManager.AppSettings(“OracleConnectionString“))
conn.Open()
Return conn
End Function
转载于:https://www.cnblogs.com/iswszheng/archive/2009/04/23/1441954.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/110921.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...