2024年2月4日发(作者:)
vb程序设计登陆界面代码详例
Imports ent
Public Class frmMagementMain
'Inherits
Dim constr As String = "User ID=sa;pwd=a;Initial Catalog=zbb;Data
Source=(local)" '定义一个变量,连接字符串
Dim sqlstr As String = "select * from manid" '定义一个变量,SQL语句
Dim mycon As New SqlConnection(constr) '定义一个变量,为一个连接对象
Dim mycom As New SqlCommand(sqlstr, mycon) '定义一个变量,为命令对象
Dim myReader As SqlDataReader '定义一个变量,阅读器
Dim i As Integer = 0
Dim userIDsys() As Array
Private Sub frmMagementMain_Load(ByVal sender As ,
ByVal e As
rgs) Handles
() '打开这个联接
myReader = eReader '把这个命令的连接送入阅读器
()
Dim k As Integer = 0
While 'while 为遍历集合的每一项,用阅读器的read的方法来读取'定义一个变量的第一项
k = k + 1
'MsgBox((1))
End While
MsgBox(k)
End Sub
Private Sub Button1_Click(ByVal sender As , ByVal e As
rgs)
Handles
' Visual Basic 2005
' Declare a new TextBox.
Dim TextBox2 As New TextBox
' Set the location below the first TextBox
= 102
= 242
' Add the TextBox to the form's Controls collection.
(TextBox2)
= "这可是我动态加的控件呀"
End Sub
Private Sub mnu_magement_Click(ByVal sender As , ByVal
e As
rgs) Handles mnu_
Dim frmlogin As frmlogin = New frmlogin
()
' = 8
' = 28
'e = True
End Sub
Private Sub Button2_Click(ByVal sender As , ByVal e As
rgs)
Handles
End Sub
End Class
/////////////////////////////////////
Imports ent
Public Class frmlogin
Dim i As Integer = 0
Dim constr1 As String = "" '定义一个变量,连接字符串
Dim sqlstr1 As String = ""
Dim mycon1 As New SqlConnection(constr1) '定义一个变量,为一个连接对象
Dim mycom1 As New SqlCommand(sqlstr1, mycon1) '定义一个变量,为命令对象
Dim myReader1 As SqlDataReader '定义一个变量,阅读器
Private Sub OK_Button_Click(ByVal sender As , ByVal e
As
rgs) Handles OK_
If = "" Or = "" Then
MsgBox("请输入用户名和密码")
Exit Sub
End If
sqlstr1 = "select * from mgpep where usernameID='" &
& "' and
passwordID='" & & "'" '定义一个变量,SQL语句
constr1 = "User ID=sa;pwd=a;Initial Catalog=SaleCD;Data
Source=(local)" '定义一个变量,连接字符串
tionString = constr1
dText = sqlstr1
() '重新打开这个联接
myReader1 = eReader '第二次把这个命令的连接送入阅读器
If eFieldCount = 0 Then
MsgBox("密码不对请重新输入~")
Exit Sub
End If
() '阅读器重新使用read方法
On Error GoTo ss
If myReader1(0) > 0 Then
e = True
sqlstr1 = "select * from mgpep"
If = 1 Then
()
End If
()
myReader1 = eReader '把这个命令的连接送入阅读器
Dim userIDsys(eFieldCount - 1, 2)
'ReDim userIDsys(10, 2)
Dim k As Integer = 0
While
(myReader1(0))
For i = 0 To 2
userIDsys(k, i) = (i)
Next
k = k + 1
End While
MsgBox("已经成功登录~")
()
()
Exit Sub
Else
MsgBox("您没有权限登录~")
()
()
Exit Sub
End If
ss:
MsgBox("您没有权限登录~")
()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As , ByVal
e As
rgs) Handles Cancel_
()
End Sub
End Class
Public ADOcn As Connection
Public Sub main()
Dim strSQLServer As String
strSQLServer = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security
Info=False;Initial Catalog=图书销售管理系统;Data
Source=longmingxueSQLEXPRESS"
Set ADOcn = New Connection
= strSQLServer
End Sub
Private Sub Command1_Click()
Dim ADOrs As New Recordset
Dim strSQL As String
Dim strXB As String
Connection = ADOcn
"select 学号 from 学生表"
If Not Then
MsgBox "该学号已经存在,不能继续添加~", vbCritical + vbOKOnly, "信息提示"
Else
If Then
strXB = "男"
Else
strXB = "女"
End If
strSQL = "Insert Into 学生表( 学号,姓名,性别)"
strSQL = strSQL + " Values('" + Text1 + "','"
strSQL = strSQL + Text2 + "','" + strXB + "')"
e strSQL
MsgBox "添加成功~", vbOKOnly, "信息提示"
End If
End Sub
本文发布于:2024-02-04 10:14:37,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170701287753261.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |