connection String在声明时工作,但在变量VB.NET中不工作

时间:2017-10-05 11:15:27

标签: sql vb.net connection-string variable-declaration

连接有效,但如果我使用按钮设置它则不行:

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)

显示与原始声明相同的连接字符串

0 个答案:

没有答案