473,487 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems Using Two Connection Objects in Same Program

Hello,

I need to access two databases on two seperate servers in
one program. One, dblocal, and another, dbserver. Once I
am done the queries on the local database, I dispose the
connection to dblocal and attempt to connect, using a
seperate connection. Once I attempt to open this second
connection, an exception is thrown. I used the connection
string built by the server explorer for both databases so
the problem should not be there, however the
datasource.tostring method returns a null string. I have
looked all over msdn and a variety of webpages and MS
ADO.Net book to find and answer. Can anyone help me out
using to connections at different times in ADO.Net.
Jul 19 '05 #1
2 1728
Please post your code and we will look at it.

Tu-Thach
-----Original Message-----
Hello,

I need to access two databases on two seperate servers in
one program. One, dblocal, and another, dbserver. Once Iam done the queries on the local database, I dispose the
connection to dblocal and attempt to connect, using a
seperate connection. Once I attempt to open this second
connection, an exception is thrown. I used the connectionstring built by the server explorer for both databases so
the problem should not be there, however the
datasource.tostring method returns a null string. I have
looked all over msdn and a variety of webpages and MS
ADO.Net book to find and answer. Can anyone help me out
using to connections at different times in ADO.Net.
.

Jul 19 '05 #2
Here is my code
Class 1
Dim strDescription As String 'str holding
desription of slide/doc
Dim strFinal As String 'holds formated
final string
Dim TF As New LSI()
Dim SL As New ApplyToStopList(cnn)
Dim MyQueue As New System.Collections.Queue()

'create description of slide/doc for reference
strDescription = MakeDescription(strData)

'prepare data for database entry
strFinal = SL.FormatFromStopList(TF.FormatForLSI(strData))
MsgBox(strFinal)

'make list of words in string and find hits
WordsInString(strFinal)

'get list of words in string
rdr = GetWords()

While (rdr.Read())
MyQueue.Enqueue(rdr(0))
MyQueue.Enqueue(rdr(1))
End While

rdr.Close()
Empty()

cnn.Dispose()

Dim DBA As New Class2()

Dim i As Integer = 0
Dim count As Integer = MyQueue.Count
While i < count
DBA.Add(MyQueue.Dequeue().ToString, path, author,
MyQueue.Dequeue().ToString, sn, strDescription, type)

i += 2
End While
DBA.Clear()
End Sub
End Class1

Class2
Private conn As System.Data.OleDb.OleDbConnection
Private cmd As System.Data.OleDb.OleDbCommand
Private rdr As System.Data.OleDb.OleDbDataReader

Public Sub New()
Me.conn = New System.Data.OleDb.OleDbConnection()
Me.conn.ConnectionString = "connectionstring"
Me.cmd = New System.Data.OleDb.OleDbCommand()
Me.cmd.Connection = Me.conn
MsgBox(conn.DataSource.ToString)
End Sub

Public Sub Add(ByVal strName As String, _
ByRef strPath As String, ByVal strAuthor As String, _
ByVal strHits As String, ByVal strSN As String, _
ByRef strDescription As String, ByVal strType As String)

'if strName is a Keyword in data
If Not (RemoveWhiteSpace(strName) = Nothing) Then
If Exists(strName) Then
'then just insert it into that table
Insert(strName, strPath, strAuthor, strHits, strSN,
strDescription, strType)
Else
'otherwise add it to the keywords and create a table for
it
AddKeyWord(strName)
AddTable(strName, strPath, strAuthor, strHits, strSN,
strDescription, strType)
End If
End If
Private Function Exists(ByVal str As String)
'connects to save pooled connection

'claims is null
MsgBox(conn.DataSource.ToString)

If Me.conn.State = ConnectionState.Closed Then
Me.conn.Open() 'faults here
End If

cmd.CommandText = "SELECT Keywords FROM keywords WHERE Keywords
= '" & str & "'"
rdr = cmd.ExecuteReader
If rdr.Read() Then
rdr.Close()
Return True
Else
rdr.Close()
Return False
End If
End Function
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2901
by: DJTB | last post by:
zodb-dev@zope.org] Hi, I'm having problems storing large amounts of objects in a ZODB. After committing changes to the database, elements are not cleared from memory. Since the number of...
0
1923
by: Jacob Lee | last post by:
I'm getting a rather bizarre error while using the socket module. If I start out disconnected from the net and then connect while the program or interpreter session is open, I do not always gain...
2
340
by: John Altland | last post by:
Hello, I need to access two databases on two seperate servers in one program. One, dblocal, and another, dbserver. Once I am done the queries on the local database, I dispose the connection...
0
1697
by: Nayt Grochowski | last post by:
Does anyone see any problem with the loading a SqlConnection into the System.Web.HttpContextCurrent.Items collection in a Page's Constructor. Then Closing and Disposing of it the OnUnload method? ...
0
959
by: Prasad Dannani | last post by:
Hi, I have some problems in reading xml data using webrequest, response and dataset objects. This program i am executing from last 6 months its worked fine. but now its throwing some exceptions....
9
2426
by: jsale | last post by:
Hello, I am having a problem with multiple users using my asp.net application - namely that if each user clicks save at the same time, some, or all, of the users crash out. Do I need to do...
2
6013
by: sidaf | last post by:
Hello, I'm writing a connection management class, but I'm running into problems with the std::list template. I want to use a list to help manage my Connection objects. The ConnectionManager...
9
2390
by: =?Utf-8?B?SG93YXJkIFNtaXRo?= | last post by:
I am using VC++ 6.0 (with SP5 installed). When using WinXP this is with SP2 installed. I am developing an instrumentation system comprising a set of networked PCs connected using TCP/IP TCP links....
0
4722
MrMancunian
by: MrMancunian | last post by:
How to create a database connection without using wizards Introduction I've seen a lot of questions on the net about getting data from, and saving data to databases. Here's a little insight how...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.