4 Steps~
1. Add oracle DB connect config in Web.config file.
2. Import System.Data.OracleClient in VB file. (exp: myjob.vb)
3. Define Connectionstring in VB file.
4. Set Getdata Function for connect DB
5. Get data
Step1:
Find the web.config file in the root Directory of aspx, and add the DB connect config.
<connectionStrings>
<add name="this_is_the_connectionstring_name" connectionString="Data Source=database_name;Persist Security Info=True; User ID=db_user_id;Password=db_password" providerName="System.Data.OracleClient" />
</connectionStrings>
Step2:
Imports System.Data.OracleClient
Step3:
Private myconnectionString as String= ConfigurationManager.ConnectionStrings("this_is_the_connection_name").ConnectionString
Step4:
Function GetTableData(ByVal queryString as String) as System.Data.Dataset
Dim ds as New System.Data.Dataset()
Try
Dim connection as New OracleConnection(myconnectionString)
Dim adapter as New OracleDataAdapter(queryString,connection)
adapter.Fill(ds)
Catch ex as Exception
End Try
Return ds
End Function
Step5:
Dim sql as String="select * from test_table "
Dim test_dataset as System.Data.Dataset=GetTableData(sql)
Now, You can use the test_dataset to do something~
Thursday, November 29, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment