Hunnicutt, Jay E. (Cont)
JEHunnicutt at nhcl.med.navy.mil
Tue Jan 3 09:33:25 CST 2006
John, If I understand your problem correctly you need to open multiple data sources at the same time. We got around this by creating separate functions to open individual data sources. Their may be a better way but this has worked well for us. Dim cn As SqlConnection Dim cmd As SqlCommand Dim dr As SqlDataReader Dim cn2 As SqlConnection Dim cmd2 As SqlCommand Dim dr2 As SqlDataReader Dim cnmass As SqlConnection Dim cmdmass As SqlCommand Dim drmass As SqlDataReader Sub OpenConnection(strDB as String) If cn Is Nothing Then cn = New SqlConnection( "server=" & SQL_SERVER & ";uid=" & DB_User & ";password=" & DB_Password & ";database=" & strDB ) cn.Open() End If If Not dr Is Nothing Then If Not dr.IsClosed() Then dr.Close() End If End Sub Sub SQL_Select(strDB as String, SQL as String) OpenConnection(strDB) cmd = New SqlCommand( SQL, cn ) cmd.CommandTimeout = 300 dr = cmd.ExecuteReader() End Sub Sub OpenConnection2(strDB as String) If cn2 Is Nothing Then cn2 = New SqlConnection( "server=" & SQL_SERVER & ";uid=" & DB_User & ";password=" & DB_Password & ";database=" & strDB ) cn2.Open() End If If Not dr2 Is Nothing Then If Not dr2.IsClosed() Then dr2.Close() End If End Sub Sub SQL_Select2(strDB as String, SQL as String) OpenConnection2(strDB) cmd2 = New SqlCommand( SQL, cn2 ) cmd2.CommandTimeout = 180 dr2 = cmd2.ExecuteReader() End Sub Sub SQL_NonSelect(strDB as String, SQL as String) OpenConnection(strDB) cmd = New SqlCommand( SQL, cn ) cmd.ExecuteNonQuery() End Sub Sub SQL_NonSelect2(strDB as String, SQL as String) OpenConnection2(strDB) cmd2 = New SqlCommand( SQL, cn2 ) cmd2.ExecuteNonQuery() End Sub Sub CloseConnection() If Not dr Is Nothing Then If Not dr.IsClosed() Then dr.Close() End If cn.Close() cn = Nothing End Sub Sub CloseConnection2() If Not dr2 Is Nothing Then If Not dr2.IsClosed() Then dr2.Close() End If cn2.Close() cn2 = Nothing End Sub Hope this helps you. Jay Hunnicutt -----Original Message----- From: John Colby [mailto:jwcolby at ColbyConsulting.com] Sent: Sunday, January 01, 2006 8:18 PM To: VBA Subject: [dba-VB] VB.net 2005 data sources screwy I have used the Data Sources wizard to build data sources, but they don't display in the data sources window. If I build another, it tells me that the previous one exists, and if I do build another, it is not displayed either. Also, if I drop a data adapter into a form it does so, but immediately says that the data source doesn't exist. Has anyone seen / worked around behavior like this? John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com