Is there a way to open only one connection and use it in many different form? Like I have this code in FORM1
Now I want to use this conn in FORM2 and FORM3 without having it to open same connection again. (FORM 1, 2, 3 are under same connection, but each form will use different table). Just open one connection in the main form (FORM1) and use it again again in other form.
Dim conn As New OracleConnection("Data Source=xxxx;User Id=xxxx;Password=xxxx;Integrated Security=no;")
Try
conn.Open()
If conn.State = ConnectionState.Open Then
Dim Part_Adapter As New OracleClient.OracleDataAdapter("SELECT PART FROM PART GROUP BY PART ORDER BY PART", conn)
Dim Part_Dataset As New DataSet
Part_Adapter.Fill(Part_Dataset)
Dim dt As New DataTable
Dim rloop As Integer
dt = Part_Dataset.Tables(0)
For rloop = 0 To dt.Rows.Count - 1
Me.ComboBox1.Items.Add(dt.Rows(rloop).Item("PART"))
Next
Else
MessageBox.Show("Connection Failed", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
conn.Close()
conn.Dispose()
Catch ex As Exception
MessageBox.Show("Failed! " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Now I want to use this conn in FORM2 and FORM3 without having it to open same connection again. (FORM 1, 2, 3 are under same connection, but each form will use different table). Just open one connection in the main form (FORM1) and use it again again in other form.