在web.config中配置:
<connectionStrings>
<add name="conn" connectionString ="Provider=服务器名;Data Source=数据库名;User ID=用户名;Password=密码;"/>
</connectionStrings>
’连接Oracle
Dim strConnect As String = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("conn").ToString()
Dim conn As OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(strConnect)
’返回数据
Public Function getTable(ByVal sql)
conn.Open()
Dim comm As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql, conn)
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(comm)
Dim dt As System.Data.DataTable = New System.Data.DataTable()
da.Fill(dt)
conn.Close()
Return dt
End Function
’返回受影响的行数
Public Function impactDate(ByVal sql)
conn.Open()
Dim comm As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql, conn)
Dim i As Integer = comm.ExecuteNonQuery
Return i
End Function
温馨提示:答案为网友推荐,仅供参考