Re: Connecting to an Oracle Database
From: Stephen A. McDonald (stephen.mcdonald_at_gottschalks.com)
Date: 05/04/04
- Next message: Stephen A. McDonald: "Re: Connecting to an Oracle Database"
- Previous message: John Jansen \(MSFT\): "Re: Trying to find an older posting"
- In reply to: David McKenzie: "Re: Connecting to an Oracle Database"
- Next in thread: Stephen A. McDonald: "Re: Connecting to an Oracle Database"
- Reply: Stephen A. McDonald: "Re: Connecting to an Oracle Database"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 4 May 2004 16:09:58 -0700
Hi David,
That doesn't make sense. When I create the command object, bind the
connection to it, create the OleDbDataAdapter, bind the command object to
it...doesn't the data adapter inherit the connection from the command
object? In addition, I don't think that you have to explicitly open and
close the connection when you fill the data adapter, at least I haven't had
to with the SQL objects and the MSDN documentation does not show them being
explicitly opened and closed either. I think that I am running into a
security issue.
I created a web service on different port and it is having the same
problems. It just hangs when I try to connect to Oracle.
Thanks for the input,
Steve...
"David McKenzie" <DavidMcKenzie@bonbon.net> wrote in message
news:uFd$togMEHA.1900@TK2MSFTNGP10.phx.gbl...
> Hi Steve,
>
> Let me start by saying that database is far from my area of expertise, but
> with some help here I managed the following code:
> Try
>
> '#1: setup the database connection info
>
> oraConn = New OracleConnection(connectionString)
>
> oraCmd = New OracleCommand
>
> '#2: query information
>
> oraCmd.CommandType = CommandType.Text
>
> oraCmd.CommandText = "SELECT ..."
>
> '#3: the OracleCommand object needs to be associated with an active
> connection
>
> oraConn.Open()
>
> oraCmd.Connection = oraConn
>
> oraDA = New OracleDataAdapter(oraCmd) 'executes the query information set
at
> #2:
>
> myDataSet = New DataSet
>
> mydatagrid = New DataGrid
>
> newColumn = New BoundColumn
>
> 'Define grid columns
>
> ...
>
> Controls.Add(mydatagrid)
>
> ' you can access the data via myDataSet.Tables(0) using the row index.
>
> ' this data can also be bound to a DataGrid with this syntax:
>
> oraDA.Fill(myDataSet)
>
> mydatagrid.DataSource = myDataSet
>
> mydatagrid.DataBind()
>
> '[Text] = Str(mydatagrid.Items.Count)
>
> oraConn.Close()
>
> Catch ex As Exception
>
> oraConn.Close()
>
> [Text] = "Oracle Connection failed" & " - " & ex.Message
>
> End Try
>
>
> "Steve" <webmaster@gottschalks.com> wrote in message
> news:hsff90ld2p7tt0qackon5tlu2k5pbmn5kh@4ax.com...
> > Hi,
> >
> > I am trying to connect to an Oracle database from my web parts. Is
> > there something that I need to configure or some special object that I
> > need to use to get a connection. I am trying to use the OleDb objects
> > in .NET and it just hangs. I use the same code in a normal webform
> > and it works perfectly. I really need to get this working. Any help
> > would be greatly appreciated.
> >
> > Environment:
> >
> > OS: Windows 2003
> > DEV: VS.NET 2003 Architect
> > DB: Oracle 8
> > APP: SharePoint Services 2003
> > SEC: Full Trust
> >
> > CODE SAMPLE:
> >
> > Private Function BuildDataset() As Dataset
> >
> > Dim strSQL As String = "SELECT * FROM <SOMETABLE>"
> > Dim iConn As OleDbConnection = New OleDbConnection("<CONN STRING>")
> > Dim iCmd As OleDbCommand = New OleDbCommand()
> > Dim iAdapter As OleDbDataAdapter
> > Dim oDS As Dataset = New Dataset
> >
> > With iCmd
> > .CommandText = strSQL.ToString
> > .CommandType = CommandType.Text
> > .Connection = iConn
> > End With
> >
> > iAdapter.Fill(oDS)
> >
> > iAdapter.Dispose
> > iCmd.Dispose
> > iConn.Dispose
> >
> > Return oDS
> >
> > This just hangs and returns nothing. If I use similar code against a
> > SQL database I get the dataset with no problems.
> >
>
>
- Next message: Stephen A. McDonald: "Re: Connecting to an Oracle Database"
- Previous message: John Jansen \(MSFT\): "Re: Trying to find an older posting"
- In reply to: David McKenzie: "Re: Connecting to an Oracle Database"
- Next in thread: Stephen A. McDonald: "Re: Connecting to an Oracle Database"
- Reply: Stephen A. McDonald: "Re: Connecting to an Oracle Database"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|