Hi Guys,
I'm new to VB.NET and want to parameterise the SQL Connection Strings in my VB.NET App. I've added a function to my Main Form to retrieve the App.config File like:
In my other forms when i want to reference the Connection String, i get an error saying getConnStr is not declared?
Any ideas why i get this when i've declared the Function as Public?
I'm new to VB.NET and want to parameterise the SQL Connection Strings in my VB.NET App. I've added a function to my Main Form to retrieve the App.config File like:
Code:
Imports System.Configuration
Imports System.Configuration.ConfigurationSettings
Public Class MainMenu
Public Function getConnStr() As String
Dim connections As ConnectionStringSettingsCollection = ConfigurationManager.ConnectionStrings
Dim constr As String = ""
constr = connections("Data_Connection").ConnectionString
Return constr
End Function
Code:
Private Sub UpdDept_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
myconnection = New SqlConnection(getConnStr()) <=============
Dim mycommand As New SqlCommand()
Comment