I'm (still) using Visual Studio 2010, and need to connect to some Oracle database. At first I did install Oracle Data Access Components (ODAC) - ODAC 12c Release 3 and Oracle Developer Tools for Visual Studio (12.1.0.2.1) latest version that support VS 2010.
Open new website, add reference Oracle.DataAccess, and sucessfully created new Data Connection to server using ODP.NET managed driver. On new aspx page add gridview and when I want to create new data source using wizard there is no Oracle source type.
Also tried with sql database source type but it is not working since I cant provide selected date value from dropdown list to query.
What to do and what I did wrong, I guess this is not OK?
Thanks for help, this is first time I'm using Oracle and VS 2010 combination.
Try
Dim connstr As String = ConfigurationManager.ConnectionStrings("LIVE").ConnectionString
Using conn As New OracleConnection(connstr)
conn.Open()
Using cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT FROM TABLE"
Using oda As New OracleDataAdapter(cmd)
Dim ds As New DataSet()
oda.Fill(ds)
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
End Using
End Using
End Using
Catch ex As Exception
End Try
At the end I load data to GridView from code behind, and used control value like for any other select, just import
Never found the Visual Studio Tools useful at all and prefer just to code it myself.
I use XML tag for the SQL statement, less fuss with punctuation, string appending and such.
Imports System.Xml.Linq.XElement
Try
Dim connectionString As String = ConfigurationManager.ConnectionStrings("AuthenticatedOracleConnectionString").ConnectionString
Dim SQL = _
<SQL>
SELECT PRODUCT_CLASS, AMOUNT_ANNUAL_CONTRACT, COUNT, TOTAL_VALUE
FROM TEST.VW_COUNT_CONTRACTS
</SQL>
Using conn As New OracleConnection(connectionString)
Using cmd As New OracleCommand(SQL.Value, conn)
conn.Open()
Using oda As New OracleDataAdapter(cmd)
Dim ds As New DataSet()
oda.Fill(ds)
Me.RadGrid1.DataSource = ds
Me.RadGrid1.MasterTableView.DataSource = ds
End Using
End Using
End Using
Catch ex As Exception
AppCalls.WriteToEventLog(ex, "Selecting VW_COUNT_CONTRACTS", "ContractAdjust.aspx.vb")
End Try
Member
59 Points
152 Posts
ODP.NET and DataSource Wizard
Sep 21, 2018 01:33 PM|dfrimmel|LINK
Hi,
I'm (still) using Visual Studio 2010, and need to connect to some Oracle database. At first I did install Oracle Data Access Components (ODAC) - ODAC 12c Release 3 and Oracle Developer Tools for Visual Studio (12.1.0.2.1) latest version that support VS 2010. Open new website, add reference Oracle.DataAccess, and sucessfully created new Data Connection to server using ODP.NET managed driver. On new aspx page add gridview and when I want to create new data source using wizard there is no Oracle source type.
Also tried with sql database source type but it is not working since I cant provide selected date value from dropdown list to query.
What to do and what I did wrong, I guess this is not OK?
Thanks for help, this is first time I'm using Oracle and VS 2010 combination.
Member
59 Points
152 Posts
Re: ODP.NET and DataSource Wizard
Sep 24, 2018 12:36 PM|dfrimmel|LINK
At the end I load data to GridView from code behind, and used control value like for any other select, just import
It was not that complicated, but I prefer to use wizard for less complex situations. Maybe someone will find this useful.
Contributor
3532 Points
1348 Posts
Re: ODP.NET and DataSource Wizard
Sep 26, 2018 11:27 PM|Lannie|LINK
Never found the Visual Studio Tools useful at all and prefer just to code it myself.
I use XML tag for the SQL statement, less fuss with punctuation, string appending and such.