Open An Oracle Database Connection In .net 2008?
May 18, 2009
I am trying to open an Oracle database connection in vb.net 2008 in order to issue a Select statement and the populate a listbox with it.
My code is as follows:
Dim orclstr As String = _
"Provider=OraOLEDB.Oracle;" & _
"Data Source=10.0.0.77;" & _
"User ID=myuser;" & _
[code]....
Obviously, I am doing something wrong, but I can't figure out what.
View 1 Replies
ADVERTISEMENT
Jan 17, 2012
I have the below mentioned code in a seperate class file for establishing connection and carry out DB transactions. I have an issue where multiple connections being opened which sometime exceed the connection pool. When I stepped through the code I found that there are codes which call ConnectDB() in a loop without calling DisconnectDB(). But I expected that the condition OraConn.State = ConnectionState.Closed should handle the situation. Somehow the condition is always satisfied hence openning another set of connection. Can you suggest where am I going wrong and also what best practice can be adopted here?
[Code]...
The connection is again opened in function updData(). While I understand that it has to be closed correctly but keeping tab on every developer is not possible. Hence I want to control it directly from the connection class by using the same connection but the condition If OraConn.State = ConnectionState.
UPDATE I have put the code in UpdateDB under a Using block and removed call to ConnectDB and DisconnectDB from function like InsertData(...). It seems that the issue has been resolved. But I would like to know in case of exception will the connection remain open? and also OraConn is a public variable defined outside Using block so will it be disposed of by the GC?
[Code]...
View 1 Replies
Jan 19, 2011
I've been viewing the tutorial at [URL]...08-088541.html but I'm still having issues creating my connection to our Oracle database. Here's my code, which uses the same connection string as one of my VB6 programs (no password required for database--Oracle picks up windows name) :
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Create connection object
Dim OraDB As String = "Data Source=databaseneme;Persist Security Info=False"
Dim conn As New OracleConnection(OraDB)
conn.ConnectionString = OraDB
conn.Open()
Me.Show()
End Sub
I've been using .NET for all of 10 mins so the error may be painfully obvious!
View 18 Replies
Apr 21, 2009
When using SQL connections in my program, will I have to open and close the connection and the data reader each time I want to access the database ?
[code]...
View 1 Replies
Sep 8, 2010
Anyone know where I might be able to find code examples for connecting to an existing Oracle DB? I need to connect to my company's oracle db so I can write strings to it, verify strings, and read from it. I've found bits and pieces of code here and there, but nothing for all of it. I am a novice programmer and I am trying to add a db connection to an existing project for our plant to access the data. Our IT dept. is helping me with the db end.
View 2 Replies
Oct 21, 2009
In my program, I have a timer with a inteval set to 1000ms. The timer is executing a MySQL-command, and right now I'm opening and closing the connection each time.
View 5 Replies
Nov 23, 2011
I have a .mdf file that I open through an Open Dialog Box and use in a ConnectionStringBuilder (where I have the user instance set to True). Later, in one of my button clicks, I try to open the connection (connection.Open()). It then gives me an error as follows: "Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances."
Here is my code:
Option Strict On
Imports System.Data.SqlClient
Public Class frmMain
[code]....
View 2 Replies
May 12, 2005
I am currently working on a login page using vb.net. I would like to know how to make connection to an access database and verify that the user logged in is a valid user
View 6 Replies
Jan 17, 2009
i want to know how to open a connection to database from vb.net
View 3 Replies
Nov 17, 2009
i am doin project using vb.net 2005 and using this sql query for connection
sql = "select username from login order by username"
con.ConnectionString = "Data Source=" & hostname & "; Initial Catalog=college;integrated security=sspi"
but m getting the following error:
Cannot open database "college" requested by the login. The login failed.Login failed for user 'CI4Admin'.
View 7 Replies
Apr 17, 2009
I am developing an application that is using a Jet database (Access 2007). The database is local to the project (e.g., on the same drive and in the project directory). Any time I attempt to access the database (to create another DataSet, etc., via designer, etc.), I get the ubiquitous "Failed to open a connection to the database" with:
No error message available, result code: E_UNEXPECTED(0x8000FFFF).
Opening the Database Explorer and attempting to attach to the database results in the above as well. There are no apparent locks on the file, etc., and I'm the sole developer for this.
View 5 Replies
Jun 22, 2010
I'm trying to a open a connection to a local database and no matter what I try it just won't work (I'm pretty new to SQL Server and VB for that matter) I tried using 'sqlconnection' with different connection strings but none of them worked or gave me any useful error messages so I tried using 'OleDBConnection' instead, this hasn't worked either and it gives me this error instead:"A first chance exception of type 'System.NullReferenceException' occurred in MyProgram.exe"
Here is the code I am currently trying:
Private Sub MemDetailsSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConnectionString = ("Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source = Database.sdf")
DataConnect = New OleDbConnection(ConnectionString)
[code]....
View 2 Replies
Dec 31, 2010
I installed SQLExpress 2008 on my computer this afternoon and have been trying to create a new database and open a connection to it. I found this code online and tried it:
Dim
conStr As
String =
"Server=MSSMLBIZ;Database=;Trusted_Connection = yes"
[code]....
View 2 Replies
Apr 26, 2012
I want to know what is the right way to close my Database connection while its open.
This is how i open my connection.[code..]
View 2 Replies
May 17, 2010
I have a connection string in my app.config:
Code:
connectionString="data source=.sql2008 ;Database=Database1; Integrated Security=FALSE; Persist Security Info=True;" />
How do I change to another database (one of many) without using multiple strings? Can I change while the connection is open?
Code:
Dim myConn As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))
View 3 Replies
Jul 17, 2009
I keeping getting an error.Seems to be the connection string.Error happens at connection.Open()
Error Message:Cannot open database "C:UsersJEREDocumentsVisual Studio 2008ProjectsBaseball2009Baseball2009DatabaseBaseball2009.sd"
requested by the login. The login failed. Login failed for user 'JERE-PCJERE'.
Imports System.Data.SqlClient
Public Class Field
Private Sub Field_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load[code]..........
View 2 Replies
Jul 6, 2009
I'm building application that will heavily use database (about 25k query's in few hours) , what is the best way to go:
A) use datareader and open new connection to the database on every client query.
B) load all the needed tables into dataset once the program loaded and use that dataset for the query's?
View 8 Replies
Aug 29, 2010
If the following is my code in VB6 to connect to Database (Oracle 8i) then what would it be for VB.Net (VS 2008)....?
[Code]....
View 1 Replies
May 31, 2011
i am developing a vb.net 2008 application. I use oledb to connect to oracle is there any way to insert a clob field in oracle from vb.net 2008 ?
View 1 Replies
Mar 27, 2012
I have put my tns connection into the .ora file and am now able to conenct to it using SQL plus and can ping it :tnsping myConn.I've also added the connection to the ODBC Manager and connecting successfully when tetsing conneciton through the ODBC tool.now i'm having an issue making a connection to it using vb.net..[code]
View 3 Replies
Jan 15, 2009
I'm trying to to connect to a Oracle database and read the content to a textbox. This is my
Dim conn As OdbcConnection
Dim connectionString As String
Try
[code]....
Connection is ok, (I think) Connection Open shows in textbox, and no errors. But I get a nullexeption on the reader, it has not been assign a value. Don't know what to do next.
View 18 Replies
Aug 22, 2011
I am seeing a strange intermittent connection failure. My application works just fine and then starts throwing connection failure exceptions. A reset of IIS is required before the app will start working again.I've been able to trace a few of the failures back to an unexpected restart of the oracle cluster but not all of them. Has anyone else seen this problem? I've searched the web but haven't found anything.
Client - Win2003 server, IIS running ASP.net 2.0.50727, code is VB.NET, ODBC connection via Oracle Client 10.2.0.1.0 Server - Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production on a Linux cluster.
[Code]...
View 4 Replies
Jan 26, 2011
i am trying to connect to it via VB.net 2010. I have been trying the following:
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim dr As OleDbDataReader
[Code]....
And i get the error on the Catch ee As Exception line: ORA-12560: TNS:protocol adapter error
I also have a tnsnames.ora file on my computer but i am unsure if i need to use that when connecting (or really, how too in the first place)? Is it needed for the code above?
I am trying to use a DNS-Less connection to the DB. Not sure if that is what it is doing in this or not?
View 2 Replies
Apr 27, 2011
I have a vb.net program that is failing, but giving no errors. I've just discovered that the code I am using is deprecated. But what is the replacment? (That seems like something useful for MSDN to list, but I'm sure not seeing it.)
Private Sub SetConnectionToDB(ByRef oCMD As OracleCommand)
Dim connectionString As String
connectionString = My.Settings.ImportDataConnectionString
[code]....
View 1 Replies
Aug 13, 2011
In my program I got multiple spots where I open a Connection to an Oracle database, read some lines via a stored procedure which returns me a cursor, put them in an IDataReader, close the connection and go on.
Now everything works fine till the point of closing the connection. I've watched the connections opened to the database via TOAD for Oracle and I figured out, that the database seems to keep an connection opened after I said m_Connection.Close and m_Connection.Dispose.
I use Oracle.DataAccess and get an error after a short time, that there are to many connections. I debuged my session and made sure, that vb performs the close() command and it does it, but the database not.
View 1 Replies
Apr 8, 2011
I'm trying to develop a simple app with vb.net in VS 2010 that could monitor the ODBC connections via DSN made on the macnhine running this app.My scenario is an application (non Vb) running on a workstation that connects to an MS Access database on a network share.
The application (non Vb) connects using a link (ODBC connection via Oracle 10G) to the tables on the Oracle side.My VB.net Application should monitor the machine running the main application for ODBC connections drops and alert me via email for example.My question is where in the framework can I find something to instantiate or reference in order to check ODBC connections states constantly as well as network disconnection issues as well so I can log and /or alert when possible for network problems and ODBC connection problems for all the applications that might run on the host (machine running my vb app).
View 3 Replies
May 1, 2009
I'm connecting succesfully to an Oracle 10g DB with an the Microsoft ODBC for Oracle driver.Regular queries without parameters work fine, but parameterized queries act as if the parameters aren't getting passed in.ex.
--this works fine
Select * from tbl1 where column1 = 'test'
--this doesn't
select * from tbl1 where column1 = ?
--odbc string parameter 'test'
Here's what my connection string looks like:
"Driver={Microsoft ODBC for Oracle}; " & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS=(PROTOCOL=TCP)" & _
[code]....
View 3 Replies
Dec 8, 2009
am trying to open a connection to an access db using the following:
vb
Dim cmd As New OleDb.OleDbCommand(QUERY, New OleDbConnection(CONNSTRING))
cmd.Connection.Open()
'dim dr
cmd.ExecuteReader
On the cmd.ExecuteReader line an error is being thrown whose message is unknown .
The connection string is as follows:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MYDB.MDB;Jet OLEDB:System Database=MYWG.MDW;User ID=USER;Password=PASSWORD;
View 4 Replies
May 14, 2010
The fact is I'm making an application, which users can install by using a Setup file...once installed the data in the database can be updated by a centralized server. To do this, they can insert a DVD/CD-ROM and export the necessary data towards it. I need to do it that way, because some of the users who really need this data will be using stand alone computers.The application gets it's data from a mdb-file and the connection remains open as long a person works with the application (maybe not the best way to do, but I know :-) )...when the user uses the application, he can perform an export...this exports the .ini-file and pictures (which works fine), but he also needs to export the mdb behind the application...I already tried connection.close() before and connection.open() after the System.IO.File.Copy...but that doesn't seems to work.
View 2 Replies
Nov 21, 2009
I'm starting using a project for smart device in windows CE 5. I'm using visual basic of v. studio 2008.I need to create a dynamic connection between a PDA (codebar lector) and an server with ORACLE 9i. The PDA connected via WIFI. But in my vb project I don't find OLEDB or ODBC elements.
View 2 Replies