Dim sqlstr As String
Dim sqlcon As New SqlConnection
Dim sqlcom As New SqlCommand
Dim ds As New DataSet
Dim da As New SqlDataAdapter
sqlcon.ConnectionString = "server=.;database=book1;integrated security=sspi"
sqlstr = "select 会员名 from hyb where 会员名='" & Me.hymtxtbox.Text & "'"
sqlcom.Connection = sqlcon
sqlcom.CommandText = sqlstr
da.SelectCommand = sqlcom
Try
sqlcon.Open()
da.Fill(ds)
If ds.Tables(0).Rows.Count = 0 Then
Me.labinfo.Text = "恭喜您,您可以注册此用户名"
Else
Me.labinfo.Text = "对不起,此用户已经有人使用了,请用其他的用户名"
End If
sqlcon.Close()
Catch ex As Exception
Me.labinfo.Text = "连接打不开"
看下这段代码 ,为什么老是"连接打不开" .