连接有效,但如果我使用按钮设置它则不行:
Public Class Form1 Private Cnstring As String
Private connection As New SqlConnection("Server=server; Database=databaseName; User Id=user; Password=password")
在button_click
中使用以下变量Cnstring = "Server=" & Server.Text & "; Database=" & Database.Text & "; User Id=" & UserID.Text & "; Password=" & Password.Text & ";"
connection.ConnectionString = Cnstring
不确定我做错了什么
MessageBox.Show(Cnstring)
显示与原始声明相同的连接字符串