快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

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

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

vb点虐 登入页面代码 vb用户登录界面代码

用vb点虐 ,后台用access 做一个登录窗口

建个模块, Dim varcnn As OleDb.OleDbConnection ReadOnly Property cnn() As OleDb.OleDbConnection

创新互联专业为企业提供德钦网站建设、德钦做网站、德钦网站设计、德钦网站制作等企业网站建设、网页设计与制作、德钦企业网站模板建站服务,十载德钦做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

Get

If varcnn Is Nothing OrElse varcnn.State ConnectionState.Open Then Dim cnstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""" My.Application.Info.DirectoryPath "\Contact.mdb"";Persist Security Info=True"

varcnn = New OleDbConnection(cnstr)

varcnn.Open()

End If

Return varcnn

End Get

登录窗体,新建一个就行了。代码Public Class LoginForm1

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

Using cmd As New OleDb.OleDbCommand("select password from tbuser where userid =?", cnn)

cmd.Parameters.Add("?", OleDbType.VarChar).Value = Me.UsernameTextBox.Text

Dim obj As Object = cmd.ExecuteScalar

If (Not IsDBNull(obj)) AndAlso (obj IsNot Nothing) AndAlso obj = PasswordTextBox.Text Then

Me.DialogResult = Windows.Forms.DialogResult.OK

Else MessageBox.Show("密码不正确!") Return

End If

End Using Me.Close()

End Sub Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

Me.DialogResult = Windows.Forms.DialogResult.Cancel

Me.Close()

End SubEnd Class 项目属性里点查看应用程序事件,写代码Namespace My ' 以下事件可用于 MyApplication:

'

' Startup: 应用程序启动时在创建启动窗体之前引发。

' Shutdown: 在关闭所有应用程序窗体后引发。如果应用程序异常终止,则不会引发此事件。

' UnhandledException: 在应用程序遇到未处理的异常时引发。

' StartupNextInstance: 在启动单实例应用程序且应用程序已处于活动状态时引发。

' NetworkAvailabilityChanged: 在连接或断开网络连接时引发。

Partial Friend Class MyApplication

Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup

Dim f As New LoginForm1

If Not f.ShowDialog = DialogResult.OK Then

End

End If

End Sub End ClassEnd Namespace

你测试一下吧。

一个vb点虐 的用户登陆页面代码

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点虐 登入页面代码 vb用户登录界面代码
文章URL:http://6mz.cn/article/ddjddph.html

其他资讯