连接已打开??
cat54 2003-08-20 10:20:13 在button1的点击事件里执行如下操作,con是sqlconnection是绝对没问题的
try
con.Open()
Catch exp As Exception
If exp.Message <> "" Then
Panel1.Visible = True
Exit Sub
End If
End Try
Dim a As New formmain()
Dim com As New SqlClient.SqlCommand()
com.CommandText = "select lastname from employees where lastname='" & TextBox1.Text & "'"
com.Connection = con
dap.SelectCommand = com
dap = New SqlClient.SqlDataAdapter(com)
dap.SelectCommand.ExecuteNonQuery()
ds.Clear()
dap.Fill(ds)
If ds.Tables(0).Rows.Count < 1 Then
'MsgBox(ds.Tables(0).Rows.Count)
MsgBox("非法用户")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
Else
loginid = TextBox1.Text
a.Show()
Me.Hide()
dap.Dispose()
ds.Clear()
com.Dispose()
End If
con.Close()
点击第一次没有关系,但连续点击就会出错说连接已经打开。
怎样解决呢