pl sql developer10 怎么连接oracle数据库

pl sql developer10 怎么连接oracle数据库,第1张

使用PL/SQL

Developer连接Oracle:

?1.

下载32位Oracle

InstantClient,并展开到某目录,例如C:\instantclient-basic-nt-11.2.0.2.0;

?2.

将系统的tnsnames.ora拷贝到该目录下

?3.

在PLSQL

Developer中设置Oracle_Home和OCI

Library:

Tools?Preferences?Oracle?

Connection

Oracle_Home:

C:\instantclient-basic-nt-11.2.0.2.0

OCI

Library:

C:\instantclient-basic-nt-11.2.0.2.0\oci.dll

?4.

在PLSQL

Developer目录下编辑如下

bat文件

,替换其

快捷方式

,启动PLSQL

Developer:

@echo

off

set

path=C:\instantclient-basic-nt-11.2.0.2.0

set

ORACLE_HOME=C:\instantclient-basic-nt-11.2.0.2.0

set

TNS_ADMIN=C:\instantclient-basic-nt-11.2.0.2.0

set

NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

start

plsqldev.exe

一般是配置方法不对造成的。

配置方法如下:

1、找到$ORACLE_HOME/client_1/network/admin目录下的tnsnames.ora文件,并用文本模式打开。

2、添加以下内容:

本地实例名=

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 数据库IP地址)(PORT = 端口号))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = 服务名)

    )

  )

3、用PL/SQL工具登录即可。

事例数据库如下: 代码如下: C# using DevExpress.LookAndFeelusing DevExpress.XtraPivotGridusing System.Data.OleDb// Create a connection object. OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0Data Source=C:\\DB\\NWIND.MDB")// Create a data adapter. OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM SalesPerson", connection)// Create and fill a dataset. DataSet sourceDataSet = new DataSet()adapter.Fill(sourceDataSet, "SalesPerson")// Assign the data source to the XtraPivotGrid control. pivotGridControl1.DataSource = sourceDataSet.Tables["SalesPerson"]// Create a row PivotGridControl field bound to the Country datasource field. PivotGridField fieldCountry = new PivotGridField("Country", PivotArea.RowArea)// Create a row PivotGridControl field bound to the Sales Person datasource field. PivotGridField fieldCustomer = new PivotGridField("Sales Person", PivotArea.RowArea)fieldCustomer.Caption = "Customer"// Create a column PivotGridControl field bound to the OrderDate datasource field. PivotGridField fieldYear = new PivotGridField("OrderDate", PivotArea.ColumnArea)fieldYear.Caption = "Year"// Group field values by years. fieldYear.GroupInterval = PivotGroupInterval.DateYear// Create a column PivotGridControl field bound to the CategoryName datasource field. PivotGridField fieldCategoryName = new PivotGridField("CategoryName", PivotArea.ColumnArea)fieldCategoryName.Caption = "Product Category"// Create a filter PivotGridControl field bound to the ProductName datasource field. PivotGridField fieldProductName = new PivotGridField("ProductName", PivotArea.FilterArea)fieldProductName.Caption = "Product Name"// Create a data PivotGridControl field bound to the 'Extended Price' datasource field. PivotGridField fieldExtendedPrice = new PivotGridField("Extended Price", PivotArea.DataArea)fieldExtendedPrice.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric// Specify the formatting setting to format summary values as integer currency amount. fieldExtendedPrice.CellFormat.FormatString = "c0"// Add the fields to the control's field collection. pivotGridControl1.Fields.AddRange(new PivotGridField[] {fieldCountry, fieldCustomer, fieldCategoryName, fieldProductName, fieldYear, fieldExtendedPrice})// Arrange the row fields within the Row Header Area. fieldCountry.AreaIndex = 0fieldCustomer.AreaIndex = 1// Arrange the column fields within the Column Header Area. fieldCategoryName.AreaIndex = 0fieldYear.AreaIndex = 1// Customize the control's look-and-feel via the Default LookAndFeel object. UserLookAndFeel.Default.UseWindowsXPTheme = falseUserLookAndFeel.Default.Style = LookAndFeelStyle.SkinUserLookAndFeel.Default.SkinName = "Money Twins"VB Imports DevExpress.LookAndFeel Imports DevExpress.XtraPivotGrid Imports System.Data.OleDb ' Create a connection object. Dim connection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0Data Source=C:\\DB\\NWIND.MDB") ' Create a data adapter. Dim adapter As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM SalesPerson", connection) ' Create and fill a dataset. Dim sourceDataSet As DataSet = New DataSet adapter.Fill(sourceDataSet, "SalesPerson") ' Assign the data source to the XtraPivotGrid control. PivotGridControl1.DataSource = sourceDataSet.Tables("SalesPerson") ' Create a row PivotGridControl field bound to the Country datasource field. Dim fieldCountry As PivotGridField = New PivotGridField("Country", PivotArea.RowArea) ' Create a row PivotGridControl field bound to the Sales Person datasource field. Dim fieldCustomer As PivotGridField = New PivotGridField("Sales Person", PivotArea.RowArea) fieldCustomer.Caption = "Customer" ' Create a column PivotGridControl field bound to the OrderDate datasource field. Dim fieldYear As PivotGridField = New PivotGridField("OrderDate", PivotArea.ColumnArea) fieldYear.Caption = "Year" ' Group field values by years. fieldYear.GroupInterval = PivotGroupInterval.DateYear ' Create a column PivotGridControl field bound to the CategoryName datasource field. Dim fieldCategoryName As PivotGridField = New PivotGridField("CategoryName", PivotArea.ColumnArea) fieldCategoryName.Caption = "Product Category" ' Create a filter PivotGridControl field bound to the ProductName datasource field. Dim fieldProductName As PivotGridField = New PivotGridField("ProductName", PivotArea.FilterArea) fieldProductName.Caption = "Product Name" ' Create a data PivotGridControl field bound to the 'Extended Price' datasource field. Dim fieldExtendedPrice As PivotGridField = New PivotGridField("Extended Price", PivotArea.DataArea) fieldExtendedPrice.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric ' Specify the formatting setting to format summary values as integer currency amount. fieldExtendedPrice.CellFormat.FormatString = "c0" ' Add the fields to the control's field collection. PivotGridControl1.Fields.AddRange(New PivotGridField() {fieldCountry, fieldCustomer, _ fieldCategoryName, fieldProductName, fieldYear, fieldExtendedPrice}) ' Arrange the row fields within the Row Header Area. fieldCountry.AreaIndex = 0 fieldCustomer.AreaIndex = 1 ' Arrange the column fields within the Column Header Area. fieldCategoryName.AreaIndex = 0 fieldYear.AreaIndex = 1 ' Customize the control's look-and-feel via the Default LookAndFeel object. UserLookAndFeel.Default.UseWindowsXPTheme = False UserLookAndFeel.Default.Style = LookAndFeelStyle.Skin UserLookAndFeel.Default.SkinName = "Money Twins"


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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存