vb点虐 登录面代码 vb的登录界面如何制作-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

vb点虐 登录面代码 vb的登录界面如何制作

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

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

创新互联公司是一家专业提供益阳企业网站建设,专注与成都网站设计、成都做网站html5、小程序制作等业务。10年已为益阳众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

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点虐 连接SQL数据库登录代码

问题应该出在你的查询语句的结果没有值,你用你的查询语句到SQL中是否有返回值?记得加上你的条件,另外,你语句里这一句是多余的.Dim s As Object = sComm.ExecuteScalar 以下语句测试正常 Dim myCn As New SqlClient.SqlConnection Try myCn.ConnectionString = sConnString myCn.Open() Dim mySQL As String = "SELECT * FROM ygzl" Dim sComm As New SqlClient.SqlCommand(mySQL, myCn) If sComm.ExecuteScalar Then Dim User_MainForm As New Form1 User_MainForm.Show() Else MsgBox("用户名或密码不正确,请重试!") End If Catch ex As Exception MsgBox(ex.Message) Finally myCn.Close() '关闭连接 End Try

求一份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的登录界面如何制作
本文来源:http://kswsj.cn/article/ddghodg.html

其他资讯