我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

登录注册代码vb.net 登录注册代码实现

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 注册问题

改为:

sql = "insert into 表1 values(用户名='" TextBox1.Text "' ,密码='" TextBox2.Text "')"

一个vb.net的用户登陆页面代码

Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) Handles Button Click

If TextBox Text = Or TextBox Text = Then

Label Text = 请确认您的输入!

Return

End If

Dim sql As String = select * from pwd where stu_id=@stu_id and pwd=@pwd

Dim m As SqlCommand = New SqlCommand(sql conn)

m Parameters Add(New SqlParameter( @stu_id SqlDbType Int ))

m Parameters( @stu_id ) Value = TextBox Text

m Parameters Add(New SqlParameter( @pwd SqlDbType Char ))

m Parameters( @pwd ) Value = TextBox Text

Dim dr As SqlDataReader

conn Open()

dr = m ExecuteReader

If dr Read Then

Session( stu_id ) = TextBox Text

dr Close()

m Cancel()

Dim sql_ As String = update stu_base set point=point+ where stu_id=@stu_id

m = New SqlCommand(sql_ conn)

m Parameters Add(New SqlParameter( @stu_id SqlDbType Int ))

m Parameters( @stu_id ) Value = Session( stu_id )

m ExecuteNonQuery()

m Cancel()

Response Redirect( detail aspx?stu_id= Session( stu_id ) )

Else

Label Text = 您还没有注册或账号密码错误

End If

End Sub

Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) Handles Button Click

TextBox Text =

TextBox Text =

lishixinzhi/Article/program/net/201311/13960

求一份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 登录注册代码实现
新闻来源:http://mswzjz.cn/article/hjcdoj.html

其他资讯