HI i have this error null reference i don't know why
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Configuration.ConfigurationSettings
Public Class Form1
Private ConName As New DataAccess
Private Sub cmdconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdconnect.Click
Dim conn As String
Dim m_server As String
Dim m_db As String
m_server = txtserver.Text
m_db = txtdb.Text
conn = "Datasource = & '" & m_server & "' &;Initial Catalog= '" & m_db & "';user id = sa;password = P@ssw0rd;"
DataAccess.GetConnectionString(conn)
End Sub
End Class
and i have this my app.config
<connectionStrings>
<add name ="Myconnname"
connectionString="Persist Security Info = false;
Data Source = jojo-pc;
Initial Catalog= BOC_DB;
User ID= sa;
Password= P@ssw0rd;
Integrated Security=SSPI;
Trusted_Connection=TRUE;
Application Name = TestDb"
providerName="System.Data.SqlClient"/>
</connectionStrings>
and this is the function under the class called dataaccess
''' <summary>
''' Function to retrieve the connection from the app.config ''' </summary>
''' <param name="conName">Name of the connectionString to retrieve</param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function GetConnectionString(ByVal conName As String) As String
'variable to hold our connection string for returning it
Dim strReturn As New String("")
'check to see if the user provided a connection string name
'this is for if your application has more than one connection string
If Not String.IsNullOrEmpty(conName) Then
'a connection string name was provided
'get the connection string by the name provided
strReturn = ConfigurationManager.ConnectionStrings(conName).ConnectionString
Else
'no connection string name was provided
'get the default connection string
strReturn = ConfigurationManager.ConnectionStrings("YourConnectionName").ConnectionString
End If
'return the connection string to the calling method
Return strReturn
End Function
Please guide im lost thanks