Click here to Skip to main content
15,894,540 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I wnat know that. Please help me .
Posted
Comments
CHill60 15-Sep-14 15:03pm    
See www.connectionstrings.com
[no name] 15-Sep-14 21:39pm    
I don't know why you want to use Oracle database, as you wont be able to use the Oracle query builder in Oracle because it does not use the same syntax as VB.NET. I suggest you do this in access/ADO. Take a look at the quick example I done. And let me know if you want to change it to another database provider.

1 solution

This rough example will get you started. I never use Oracle, but this Solution should get you moving. Reference for your connection string is here: ConnectionsStrings[^]

NOTE: You will also need to create a reference to the Oracle Client.

VB
Dim ConString As String = ("Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;") 'This s your connection string 'Something like this will create your connection string. Of course you need to edit the values to match that of your own database configuration. 

Private Sub B1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    ReadData(connectionString:=ConString) 'Pass the connection to the read data sub.

End Sub
Dim ConString As String = ("Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;") 'This s your connection string
Private Sub ReadData(ByVal connectionString As String)

    Dim eOrcCon As New OracleConnection(connectionString) 'Create the Oracle connection.
    Dim iCommand As New OracleCommand() 'Create your command.
    Dim reader As OracleDataReader 'Create an instanace of the reader.

    eOrcCon.Open() 'Open the connection.
    iCommand.Connection = eOrcCon 'Assign the command the connecion to use.
    iCommand.CommandText = "Put your command here." 'You need to put your statement here

    iCommand.CommandType = CommandType.StoredProcedure 'Set Command Type

    iCommand.Parameters.Add(New OracleParameter("N_EMPNO", OracleType.Number)).Value = 7369 'Modified example of parameters from MSDN
    iCommand.Parameters.Add(New OracleParameter("IO_CURSOR", OracleType.Cursor)).Direction = ParameterDirection.Output 'Same ^

    reader = iCommand.ExecuteReader() 'Execute to get your result

    While (reader.Read()) 'This will be false by default if there is nothing to read. Thus begins reading if there is data available.
        ' This is where you receive your values from the tables etc
    End While
    reader.Close() 'Close the reader
    eOrcCon.Close() 'And the connection
    'If you use use Using blocks, you won't need to close the connections as this is disposed of in the using blocks. Search MSDN for Using Blocks
End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900