How to display a login failure messagebox for App.Config connection string

后端 未结 1 1413
北海茫月
北海茫月 2021-01-26 04:51

I use the following connection string and am able to log into SQL 2008 R2 Server.

My.Settings.Item(\"CustomerConnectionString\") = \"Data Source=FAROOK-PC\\SQLEX         


        
相关标签:
1条回答
  • 2021-01-26 05:01

    use Try Catch Block. If connection fails use yor message box in catch block.

    Dim sqlCnn As New SqlConnection
    Dim connString as string = "Your Connection String"
    Try
       sqlCnn = New SqlConnection(connString)
       sqlCnn.open()
    Catch ex As SqlException
       MsgBox("Login Failed")
    
    End Try
    
    0 讨论(0)
提交回复
热议问题