我从以下代码中得到错误“表达式不是方法VS2010”:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn.ConnectionString = connstring
If Not conn.State = ConnectionState.Open Then
*ConnectionState*.Open()
MsgBox("open")
Else
MsgBox("close")
End If
End Sub
答案 0 :(得分:3)
那应该是conn.Open
:
If Not conn.State = ConnectionState.Open Then
conn.Open()
MsgBox("open")
Else
MsgBox("close")
End If
ConnectionState是一个枚举,而不是一个变量。