Try
Dim a As String
If TextBox2.Text = TextBox3.Text Then
a = "insert into t_login (id,password)values('" & Trim(TextBox1.Text) & "','" & Trim(TextBox2.Text) & "')"
Dim mycom As New SqlCommand(a, SqlConnection1)
SqlConnection1.Open()
mycom.ExecuteNonQuery()
SqlConnection1.Close()
MsgBox("新增成功")
Else
MsgBox("两次密码不相同")
End If
Catch ex As Exception
MsgBox("该用户已经存在")
End Try
這個不知是不是你要的