Dim x1 As String = e.Form.Controls("Textbox1").Value 'Textbox1=用户名
Dim x2 As String = e.Form.Controls("Textbox2").Value 'Textbox2=密码
Dim cmd As New SQLCommand
cmd.ConnectionName ="注册" '注册为你的数据表名
If x1 = "" OrElse x2 = "" Then
Messagebox.show("请输入用户名和密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select Top 1 用户名 From {注册} Where 用户名 = '" & x1 & "'"
If cmd.ExecuteScalar > "" Then
Messagebox.show("新建用户失败,已经能存在同名用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Insert Into {注册} ([用户名],[密码]) Values (" & x1 & ", '" & x2 & "')"
End If
e.Form.Close()
[此贴子已经被作者于2012-5-8 14:05:51编辑过]