DOTNET零碎要点---1.vb.net利用Oracle.DataAccess.dll链接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数据库
  a.安装客户端的情况下引用:
    引用oracle安装目录下        

product/11.2.0/client_1/ODP.NET/bin/2.x/Oracle.DataAccess.dll
  b.直接安装了oracle到本机的话在
    D:\oracle\product\10.2.0\db_1\BIN下
  c.数据库链接以及操作代码 
    Private Function dbconnect() As Boolean
        Dim strConn = "Data Source=192.168.1.110/orcl;User ID=test;Password=orcl"
        Dim dbcmd As OracleCommand
        Dim dt = New DataTable("ds")
        Dim dbConnection As OracleConnection
        Try
            dbConnection = New OracleConnection(strConn)
            dbConnection.Open()
            dbcmd = dbConnection.CreateCommand
            dbcmd.CommandText = "select * from student"
            Dim da As OracleDataAdapter = New OracleDataAdapter(dbcmd)
            da.Fill(dt)
            DataGridView1.DataSource = dt '这时候可以把dt的值直接赋值给

DataGridview1控件
        Catch ex As Exception
            Exit Function
        End Try
    End Function


你可能感兴趣的:(DOTNET零碎要点---1.vb.net利用Oracle.DataAccess.dll链接Oracle数据库)