Dim strcmd As String
Dim sqlcn As SqlConnection = New SqlConnection(strcon)
sqlcn.Open()
strcmd = "select id from t_login"
Dim sqlcmd As SqlCommand = New SqlCommand(strcmd, sqlcn)
Dim dr As SqlDataReader
dr = sqlcmd.ExecuteReader
Do While dr.Read
If Trim(TextBox1.Text) = dr.Item(0) Then
MsgBox("該用戶名已存在!")
Exit Sub
Else
Dim sqlcmdcommandtext As String
sqlcn.Close()
sqlcn.Open()
sqlcmdcommandtext = "insert into t_login (id) values ('" & CStr(Trim(TextBox1.Text)) & "')"
sqlcmd.ExecuteNonQuery()
MsgBox("申請成功,請登入!")
Exit Sub
End If
Loop
謝謝你了,這是我做的,你幫忙看下有什么問題