vb.net软件注册代码 vb编写软件注册

vb.net怎么写注册代码

Private Sub 提交_Click()

创新互联建站从2013年开始,先为克山等服务建站,克山等地企业,进行企业商务咨询服务。为克山企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

Dim stemp As String

Dim rs As ADODB.Recordset

Set rs = New ADODB.Recordset

stemp = "select * from user"

rs.Open stemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

If Me!密码 确认密码 Then

MsgBox "两次输入的密码不一致,请重新输入", vbExclamation, "Error"

Exit Sub

Else

stemp = "insert into user"

stemp = stemp "(用户名,密码,身份证号)"

stemp = stemp " values('" Me!用户名 "','" Me!密码 "','" Me!身份证号 "')"

DoCmd.RunSQL stemp1

Set rs = Nothing

End If

MsgBox "The information of register have saved already!", vbExclamation, "information"

End Sub

求一份VB.NET的注册页面的代码

创建完相应的用户名,密码控件之后,输入以下代码:

Imports System.Data.OleDb

Public Class Form1

Private Sub cmdok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdok.Click

Dim m_username As String

Dim m_userpwd As String

Dim cmd_result As MsgBoxResult

Dim m_da As New OleDbDataAdapter

Dim m_ds As New DataSet

Dim m_command As New OleDbCommand

Dim strsql As String

m_username = txtusername.Text

m_userpwd = txtuserpwd.Text

strsql = " select * from user_info where username='" m_username "' and userpwd='" m_userpwd "'"

OleDbConnection1.Open()

m_command.CommandType = CommandType.Text

m_command.CommandText = strsql

m_command.Connection = OleDbConnection1

m_da.SelectCommand = m_command

m_da.Fill(m_ds, "user_info")

If m_ds.Tables("user_info").Rows.Count 0 Then

cmd_result = MsgBox("欢迎登录", MsgBoxStyle.OKOnly, "提示")

Else

MsgBox("登录失败,请确认用户名和密码")

End If

End Sub

End Class

VB.NET 注册代码

写两个函数,一个检测是否有重复用户,第二个插入

检测属用户是否存在

private function checkUser(byval uname as string) as boolean

dim sql as string = "select * from [user] where username=" uname

dim cmd as sqlcommand = new sqlcommand(sql,conn)

dim read as sqldatareader = cmd.excutereader

dim result as boolean = read.hasrows

cmd=nothing

return result

end function

新增用户

private sub adduser(byval uname as string,byval password as string)

if checkUser(uname)

messagebox.show("用户已存在")

exit sub

end if

try

dim sql as string = "insert into [user](username,password) values(@uname,@upass)"

dim cmd as sqlcommand = new sqlcommand(sql,conn)

cmd.parameters.add("@uname",sqldbtype.varchar).value=uname

cmd.parameters.add("@upass",sqldbtype.varchar).value=password

cmd.ExecuteNonQuery

cmd=nothing

messagebox.show("用户添加成功!")

catch ex As Exception

messagebox.show("用户添加失败!" + ex.message)

end try

end sub


名称栏目:vb.net软件注册代码 vb编写软件注册
本文链接:http://pwwzsj.com/article/dojogoh.html