精华内容
下载资源
问答
  • VB.NET连接oracle数据库

    2017-05-15 20:32:26
    VB.net连接oracle数据库
  • VB.NET连接Oracle数据库

    2021-01-03 12:33:04
    VB.NET连接Oracle数据库 老菜鸟,不在江湖多年,刀已锈迹斑斑,唯胜记忆中的影约的招式。 最近有些项目需求,准备自己操刀,只好重新磨刀,俗话说得好,磨刀不误砍柴功嘛。首先查阅大量资料和书籍,大量略读,重点...

    VB.NET连接Oracle数据库

    老菜鸟,不在江湖多年,刀已锈迹斑斑,唯剩记忆中的影约的招式。
    最近有些项目需求,准备自己操刀,只好重新磨刀,俗话说得好,磨刀不误砍柴功嘛。首先查阅大量资料和书籍,大量略读,重点精读,边读边实践。下载安装VS2019、Oracle11G等过程倒是平淡未出问题,在连接数据库过程中遇到了问题,几经周折才解决,但对深层次原因还是不甚了解,请大神指教。

    问题描述
    项目中添加了引用,用VB.NET编写代码如下:
    Imports System.Data.OracleClient
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim connStr As String
    connStr = “Data source=orcl;Persist Security Info=True;user id=system;password=orcl”
    Dim OraDBConn As New OracleConnection(connStr)
    Try
    OraDBConn.Open()
    MsgBox(“Database Opened!”)
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    End Sub
    End Class
    调试时出现错误信息如下:

    在这里插入图片描述

    解决方法
    经过多方查阅资料后发现,System.Data.OracleClient已经过时,新版本中采用Oracle.ManagedDataAccess.Client,更新程序如下:
    Imports Oracle.ManagedDataAccess.Client
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim connStr As String
    connStr = “user id=system;password=orcl;data source=localhost:1521/orcl; Pooling=false;”
    Dim OraDBConn As New OracleConnection(connStr)
    Try
    OraDBConn.Open()
    MsgBox(“Database Opened!”)
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    End Sub
    End Class
    问题解决。

    展开全文
  • VB.NET连接ORACLE数据库

    2015-12-30 15:16:01
    引用了Oracle.ManagedDataAccess,打成安装包十分方便。
  • VB.NET 连接ORACLE数据库

    千次阅读 2017-05-19 11:44:32
    Imports System.Data Imports System.Data.Odbc Dim strSQL As String Dim objRecordSet As Odbc.OdbcDataReader strSQL = "select t.id as UNITTYPEID ,t.name AS NAME, u.id as UNITCONTENTID" _
    Imports System.Data
    Imports System.Data.Odbc
    
    Dim strSQL As String
            Dim objRecordSet As Odbc.OdbcDataReader
    
    strSQL = "select t.id as UNITTYPEID ,t.name AS NAME, u.id as UNITCONTENTID" _
                 & " from sys_aunittypes_c t, sys_cunitsincappfile_c u,sys_ccappfiles_c f" _
                 & " Where F.id = u.CAPPFileID And u.UnitTypeID = t.id AND f.id = " & lngCappFileID _
                 & " order by u.unitorder"
    
            objRecordSet = GetDataReader(strSQL)
            While (objRecordSet.Read())
                lUnitContentID = CLng(objRecordSet.Item("UNITCONTENTID").ToString)
                lUnitTypeID = CLng(objRecordSet.Item("UNITTYPEID").ToString)
                strUnitName = objRecordSet.Item("NAME").ToString
    
            End While
            objRecordSet.Close()
    
     Public Function GetDataReader(ByVal strSql As String) As Odbc.OdbcDataReader
            On Error GoTo ErrRet
            GetDataReader = Nothing
            Dim objDataReader As Odbc.OdbcDataReader
            'Public g_objEntityConn As Odbc.OdbcConnection
            g_objEntityConn = New OdbcConnection(g_strConnectString)
            If g_objEntityConn.State = ConnectionState.Closed Then
                g_objEntityConn.Open()
            End If
            If g_objEntityConn Is Nothing Then
                Exit Function
            End If
            Dim cmm As OdbcCommand
            cmm = New OdbcCommand(strSql, g_objEntityConn)
    
            objDataReader = cmm.ExecuteReader(CommandBehavior.CloseConnection)
    
            GetDataReader = objDataReader
            Exit Function
    ErrRet:
            MsgBox(Err.Description)
        End Function



    展开全文
  • vb.net连接oracle数据库

    千次阅读 2011-12-21 10:24:31
    Imports Oracle.DataAccess.Client Imports System.Runtime.CompilerServices Imports System.Threading Imports Microsoft.VisualBasic.CompilerServices Public Class OracleDB Public Shared OraConnection
    Imports Oracle.DataAccess.Client
    Imports System.Runtime.CompilerServices
    Imports System.Threading
    Imports Microsoft.VisualBasic.CompilerServices
    
    Public Class OracleDB
        Public Shared OraConnection As String
    
        Public Shared Function CallProcedure(ByVal strProcedureName As String, ByVal strParameters As IList) As Boolean
            Dim connection As OracleConnection = New OracleConnection()
            Dim adapter As OracleDataAdapter = New OracleDataAdapter()
            Dim command As OracleCommand = New OracleCommand()
            connection.ConnectionString = OraConnection
            connection.Open()
            command = New OracleCommand(strProcedureName, connection)
            command.CommandType = CommandType.StoredProcedure
            Dim num2 As Integer = strParameters.Count - 1
            Dim i As Integer
            For i = 0 To num2 Step i + 1
                command.Parameters.Add("", RuntimeHelpers.GetObjectValue(strParameters(i)))
            Next
            Try
                command.ExecuteNonQuery()
                command.Parameters.Clear()
                connection.Close()
            Catch exception1 As Exception
                Return False
            End Try
            Return True
        End Function
    
        Public Shared Function CallTranscation(ByVal ArrayStrSQL() As String) As Boolean
            Dim dbCN As OracleConnection = New OracleConnection()
            Dim adapter As OracleDataAdapter = New OracleDataAdapter()
            Dim command As OracleCommand = New OracleCommand()
            dbCN.ConnectionString = OraConnection
            dbCN.Open()
            Dim transaction As OracleTransaction = dbCN.BeginTransaction()
            Try
                Dim num2 As Integer = Information.UBound(ArrayStrSQL, 1)
                Dim i As Integer
                For i = 0 To num2 Step i + 1
                    Dim strSQL As String = ArrayStrSQL(i)
                    Thread.Sleep(100)
                    ExecuteTranscationSQL(dbCN, strSQL, "")
                Next
                transaction.Commit()
            Catch exception1 As Exception
                ProjectData.SetProjectError(exception1)
                Dim exception As Exception = exception1
                If Not transaction Is Nothing Then
                    transaction.Rollback()
                    Return False
                End If
            End Try
            Return True
        End Function
    
        Public Shared Function ExecuteSQL(ByVal strSQL As String, Optional ByVal dsTableName As String = "") As DataSet
            Dim connection As OracleConnection = New OracleConnection()
            Dim adapter As OracleDataAdapter = New OracleDataAdapter()
            Dim command As OracleCommand = New OracleCommand()
            Dim dataSet As DataSet = New DataSet()
            connection.ConnectionString = OraConnection
            connection.Open()
            command.CommandText = strSQL
            command.CommandTimeout = 0
            adapter.SelectCommand = command
            adapter.SelectCommand.Connection = connection
            If dsTableName = "" Then
                adapter.Fill(dataSet)
            Else
                adapter.Fill(dataSet, dsTableName)
            End If
            connection.Close()
            Return dataSet
        End Function
    
        Public Shared Function ExecuteTranscationSQL(ByVal dbCN As OracleConnection, ByVal strSQL As String, Optional ByVal dsTableName As String = "") As Integer
            Dim command As OracleCommand = New OracleCommand()
            command.Connection = dbCN
            command.CommandText = strSQL
            command.CommandType = CommandType.Text
            Return command.ExecuteNonQuery()
        End Function
    
        Public Shared Function TestDBConnect() As Boolean
            Dim connection As OracleConnection = New OracleConnection()
            Dim adapter As OracleDataAdapter = New OracleDataAdapter()
            Dim command As OracleCommand = New OracleCommand()
            Dim dsset As DataSet = New DataSet()
            Try
                connection.ConnectionString = OraConnection
                connection.Open()
            Catch exception1 As Exception
                Return False
            End Try
            Return True
        End Function
    End Class
    
    
    

     
    展开全文
  • vb.net 连接Oracle数据库

    千次阅读 2011-04-14 13:31:00
    "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID= 用户名 ;" & _  "Password= 密码 ;Data Source= 数据源 ;Persist Security Info=False"     Oraclecn = New ADODB.Connection...

      

            

    '------------------------第1种-------------------------------------

            '在引用里添加ADODB

    Public Oraclecn As ADODB.Connection

    Public Orastr As String

     

    Public Sub OracleCon()

            Orastr = "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=用户名;" & _

                     "Password=密码;Data Source=数据源;Persist Security Info=False"

     

            Oraclecn = New ADODB.Connection

     

            With Oraclecn

                .Mode = ADODB.ConnectModeEnum.adModeReadWrite

                .CursorLocation = ADODB.CursorLocationEnum.adUseClient

                .ConnectionString = Orastr

                .ConnectionTimeout = 60

                .Open()

            End With

    End Sub

     

    '------------------------第2种-------------------------------------

     

    Imports System.Data.OleDb

     

     

    Public Oraclecn As OleDbConnection

     

    Public Orastr As String

     

    Public Sub OracleCon()

        Oraclecn = New ADODB.Connection

        OraStr = "Provider=OraOLEDB.Oracle;Data Source=数据源;User Id=用户名;Password=密码;"

    Oraclecn.ConnectionString = OraStr

    Oraclecn.Open()

     

     

     

    End Sub

    展开全文
  • 我用VB.NET把数据写入ORACLE数据库,insert into table (NO,NAME,ADDRESS) values(1,'li','beijing')。遇到两个问题: 1,如何实现序号递增,因为不知道前面是否已经写过数据,或者是写了多少行 2,'li' 和 '...
  • 關於 VB.Net 存取 Oracle 資料庫 介紹 4 種 VB.Net 存取 Oracle 資料庫的基本寫法 u 傳統的 ADO Connection 開 Recordset 並把資料 “餵給” 新一代 ADO.Net 的 DataSet 並做資料存取 u ADO.Net ...
  • VB.net操作oracle数据库

    千次阅读 2012-11-29 10:33:57
    首先,我用VS2010开发对oracle10g数据库的操作,结果发现微软自带的System.Data.OracleClient已经有一些常用对象提示过时;网上说最好用oracle自带的ODP.net操作。 我到oracle网站下载ODAC这个安装包,还注册了...
  • 我利用vb.net编写asp.net连接oracle数据库时,提示:不支持关键字: “(kstsdb”。 我的具体代码是这样写的 Dim constring As String = "(KSTSDB=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.12.15.203)(PORT=...
  • //在vs里面安装ODP.NET连接oracle数据库 在程序包管理器控制台里面输入命令: Install-Package Oracle.ManagedDataAccess 相关网址: https://www.nuget.org/packages/Oracle.ManagedDataAccess/12.1.24160719 ...
  • .NET连接Oracle数据库(对数据的增删改查) --------------------------WebForm1.aspx-----------------------------------------------------             onclick
  • VB.NET连接远程Oracle

    2021-02-10 10:30:34
    VB.NET连接远程Oracle 引言 添加引用 测试连接 引言 大概去年的这个时候,我写了一篇使用MATLAB连接远程Oracle的博文。这段时间由于需要,要求使用VB.NET连接远程Oracle,折腾了好几天,把过程记录下来。 可能是...
  • 解析VB.NET如何连接数据库

    千次阅读 2013-05-27 12:57:54
    VB.NET连接数据库有很多方法,这里我们向大家主要介绍三种方法:用The SQL Server .NET Data Provider连接数据库;用The OLE DB .NET Data Provider连接数据库;用The ODBC .NET Data Provider连接数据库 AD: ...
  • vb.net代码如下 Dim ss As String ' 指定连接字符串==〉0k ss = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.77.128)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))"...
  • VB.NET连接Oracle共通模块

    千次阅读 2012-06-14 20:51:19
    2、将DBLink.vb添加到现有项目中   ———————————————————华丽的分割线————————————————————— Option Strict Off Option Explicit On Imports System.Data....
  • VB.NET编写的ORACLE数据库线程查询工具
  • 1.vb.net利用Oracle.DataAccess.dll链接Oracle数据库 DOTNET学习笔记---1.vb.net利用Oracle.DataAccess.dll链接Oracle数据库 2013-02-27 1.vb.net利用Oracle.DataAccess.dll链接Oracle数据库  ...
  • 我正在使用Microsoft ODBC for Oracle驱动程序成功连接Oracle 10g数据库.没有参数的常规查询可以正常工作,但参数化查询就好像没有传入参数一样.恩.--this works fineSelect * from tbl1 where column1 = 'test'--...
  • VB.NET连接数据库总结

    2007-12-30 09:04:00
    VB.NET连接数据库总结一、先介绍ADO.NET和ODBC.NETADO .NET由Microsoft ActiveX Data Objects (ADO)改进而来,它提供平台互用和可收缩的数据访问功能,是Visual Basic.NET进行数据库编程所使用的重要工具。...
  • 小弟刚学asp.net现在数据库连接完成,我在某一列插入了数据,我想在页面中读取出来,我使用的代码为 Dim sqlStr As String = "select*from AGVNEW1 where agvId" Dim myCmd As OracleCommand = New OracleCommand...
  • Imports System.Data.OleDbImports SystemImports co Public Class DataAccess#Region "变量/常量"Private conn As OleDbConnection OLEDB连接对象Private connected As Boolean = False 连接标识Private
  • vb.net連接Oracle数据库

    2018-07-05 10:13:00
    Imports Oracle.DataAccess.Client '導入命名空間 Public Class Form1 Dim Sql As String Public SqlTP As OracleConnection = New OracleConnection("Password= ""密碼"";Persist Security Info=True;User ID=帳...
  • .net中使用ODP.net访问Oracle数据库(无客户端部署方法) 分类:c#database2012-01-05 15:346330人阅读评论(1)收藏举报 oracle数据库.netcomponentsdll ODP.net是Oracle提供的数据库访问类库,其功能和效率上都...
  • 如题,按连接字符串连接后可使用select等数据库操作命令,但如何使用imp/exp命令。
  • VB.NET连接数据库的几种方法

    千次阅读 2007-07-06 15:16:00
    VB.NET连接数据库的几种方法ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.VisualStudio.v80.chs/WD_ADONET/html/745c5f95-2f02-4674-b378-6d51a7ec2490.htm Microsoft Visual Basic.NET 是Microsoft Visual Basic...
  • vb.net数据库连接ppt

    2010-09-17 00:04:01
    vb.net中的数据库连接操作说明和概念讲解,涉及到oracle,sql等数据库连接知识
  • vb.net连接服务器上的oracle数据库时报“ORA-12541:TNS:无监听程序”的错误,代码如下 Imports Oracle.ManagedDataAccess.Client Dim strConnect As String = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 9,298
精华内容 3,719
关键字:

vb.net连接oracle数据库