大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
创手慧李建完相应的用户名,密码控件之后,输入以下代码:碧悔
创新互联公司是一家以网络技术公司,为中小企业提供网站维护、成都网站建设、成都做网站、网站备案、服务器租用、域名申请、软件开发、小程序开发等企业互联网相关业务,是一家有着丰富的互联网运营推广经验的科技公司,有着多年的网站建站经验,致力于帮助中小企业在互联网让打出自已的品牌和口碑,让企业在互联网上打开一个面向全国乃至全球的业务窗口:建站联系热线:028-86922220
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
把异常堆毕带栈打出来看看
补充:
在更新或提交的时候出现的错误,可能是某个控件的值,字符串等无法团正转换成数字,塌数悔你检查一下是不是不小心弄错了控件了
建个模块, 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
你测试一下吧。
闷谈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