Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle Connection

Status
Not open for further replies.

dawtes

Programmer
Jun 23, 2005
31
US
Here is my question: I have a code that work fine with access database and I want to use this code to work with oracle database. I have tried to change the connection string, command object and data reader but I do not seem to have luck yet. Can someone take a look at it and help me to fix this code to work with oracle database.

<%@ import namespace="System.Data.OleDb"%>
<Html>
<Head>
<Title>connecting to a Database using vb</Title></head>
<script runat="server" language="VB">
Dim i As Integer
Dim filename as string
Dim sb as System.Text.StringBuilder
dim cn as OleDbConnection
Dim cmd as OleDbCommand
Dim dr as OleDbDataReader
Dim a as string


Sub Click(ByVal sender as System.Object, ByVal e as System.EventArgs)

cn = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;"& _
"Data Source=c:\Inetpub\ & _
"Dorknozzle.mdb")


filename = "products.csv"
cmd = New OleDbCommand("Select * from employees ",cn)
cmd.Connection.open()
dr = cmd.ExecuteReader()
sb = New System.Text.StringBuilder

'for field name
For i=0 to dr.FieldCount-1
If i < (dr.FieldCount-1) then
sb.Append(Chr(34)&dr.GetName(i)&Chr(34)&",")
Else
sb.Append(Chr(34)&dr.GetName(i)&Chr(34)& VbCrLf)
End If
Next


'for field value
While dr.Read()
For i=0 to dr.FieldCount-1
If i < (dr.FieldCount-1) then
sb.Append(Chr(34)&dr.GetValue(i).ToString & Chr(34)&",")
Else
sb.Append(Chr(34)&dr.GetValue(i).ToString & Chr(34)& VbCrLf)
End if
Next

End while
dr.close()
cn.Close()
Response.ContentType ="Application/x-csv"
Response.AddHeader("content-disposition","attachment;filename="""& filename &"""")
Response.Write(sb.ToString)
Response.End()

End Sub
</script>


<Body>
<form runat="server">
<asp:LinkButton id="btnSubmit" runat="Server" text=" Comma-Separated Values" OnClick="Click"/></p>
</form>
</Body>
</Html>
 
what is your oracle connectionstring?

try using the oracleclient

and did you install the oracle client tools on the server and try to make an odbc connection?

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Try reading some of the FAQ's:

faq855-5780
faq855-5662 (as chrissie points out above you can use the OracleClient instead of the SQLClient in this example)



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top