Hi All

I am trying to connect to my database from the front end in VB.NET 2003, the connection strings that i have tried are not working at present. I have VB.NET 2003 program from last year but that was using access as the back end and VB.NET 2003 as the front end. This year i must use oracle as the back end and Vb.Net 2003 as the front end. The connection strings that i have tried do not seem to be correct but i will keep trying it is probably something simple. Yes the database does connect through odbc and the tns file is correct

hi,
Use below any of the codings:

using ODBC
'Imports the ODBC Namespace
Imports System.Data.Odbc
'Declare the Connection
'Here i used the DSN
'To create DSN
1. Start->Run-> ODBCAD32
2. Select User Dsn Tab
3. Click Add
4. Select the Provider for oracle "Microsoft ODBC for ORACLE"
5. Type the any text in the Data source name
6. Enter the username of the oracle
7. Enter the Hoststring of the oracle

Dim con As Odbc.OdbcConnection = New OdbcConnection("DSN=chit;uid=scott;pwd=tiger;")
'Codings written in Try Block
Try
con.Open()
Dim cmd As OdbcCommand = New OdbcCommand
cmd.CommandText = "select * from abcd"
cmd.Connection = con
Dim rdr As OdbcDataReader = cmd.ExecuteReader
While rdr.Read
TextBox1.Text = rdr(0)
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try

using ODBC
'Imports the OLEDB Namespace
Imports System.Data.OleDb
' Here i used the provider
Dim con As OleDbConnection = New OleDbConnection("Provider=MSDAORA.1;Password=tiger;User ID=scott ;Data Source= css;Persist Security Info=True")
Try
con.Open()
Dim cmd As OleDbCommand = New OleDbCommand
cmd.CommandText = "select * from abcd"
cmd.Connection = con
Dim rs As OleDbDataReader = cmd.ExecuteReader
While rs.Read
TextBox1.Text = rs(0)
End While
Catch ex As Exception
msgbox (ex.message)
End Try

Best Regards
Shailu:)

Hi All

I am trying to connect to my database from the front end in VB.NET 2003, the connection strings that i have tried are not working at present. I have VB.NET 2003 program from last year but that was using access as the back end and VB.NET 2003 as the front end. This year i must use oracle as the back end and Vb.Net 2003 as the front end. The connection strings that i have tried do not seem to be correct but i will keep trying it is probably something simple. Yes the database does connect through odbc and the tns file is correct

hi,

Use below codings:

using ODBC
'Imports the ODBC Namespace
Imports System.Data.Odbc
'Declare the Connection
'Here i used the DSN
'To create DSN
1. Start->Run-> ODBCAD32
2. Select User Dsn Tab
3. Click Add
4. Select the Provider for oracle "Microsoft ODBC for ORACLE"
5. Type the any text in the Data source name
6. Enter the username of the oracle
7. Enter the Hoststring of the oracle

Dim con As Odbc.OdbcConnection = New OdbcConnection("DSN=chit;uid=scott;pwd=tiger;")
'Codings written in Try Block
Try
con.Open()
Dim cmd As OdbcCommand = New OdbcCommand
cmd.CommandText = "select * from abcd"
cmd.Connection = con
Dim rdr As OdbcDataReader = cmd.ExecuteReader
While rdr.Read
TextBox1.Text = rdr(0)
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try

using OLEDB
'Imports the OLEDB Namespace
Imports System.Data.OleDb
' Here i used the provider
Dim con As OleDbConnection = New OleDbConnection("Provider=MSDAORA.1;Password=tiger;User ID=scott ;Data Source= css;Persist Security Info=True")
Try
con.Open()
Dim cmd As OleDbCommand = New OleDbCommand
cmd.CommandText = "select * from abcd"
cmd.Connection = con
Dim rs As OleDbDataReader = cmd.ExecuteReader
While rs.Read
TextBox1.Text = rs(0)
End While
Catch ex As Exception
msgbox (ex.message)
End Try

Best Regards
Shailu:)

Hi All

I am trying to connect to my database from the front end in VB.NET 2003, the connection strings that i have tried are not working at present. I have VB.NET 2003 program from last year but that was using access as the back end and VB.NET 2003 as the front end. This year i must use oracle as the back end and Vb.Net 2003 as the front end. The connection strings that i have tried do not seem to be correct but i will keep trying it is probably something simple. Yes the database does connect through odbc and the tns file is correct

This article has been dead for over six months. Start a new discussion instead.