私を助けてください。私は数週間ここにこだわってきた。私はそれを解決する方法を知らない。グローバルモジュールのフォームに関連しているグローバルモジュール。 ADODB接続とSQLサーバー
Imports System.Text.RegularExpressions
Module globalmodule
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public rss As New ADODB.Recordset
Public trs As New ADODB.Recordset
Public sql As String
Public Function opendb()
If conn.State = 1 Then conn.Close()
conn.Open("Provider=SQLOLEDB.1;Data Source=ACER;Initial Catalog=dbEmployee;Integrated Security=True;")
Return 0
End Function
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)
If emailAddressMatch.Success Then
EmailAddressCheck = True
Else
EmailAddressCheck = False
End If
If EmailAddressCheck = False Then
MsgBox("Entervalid E-mail ID")
End If
End Function
Public empid As String
End Module
フォーム1:
は、ここに私の接続コードです。ここで
はコードです:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
opendb()
End Sub
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
If cmbutype.Text = "Employee" Then
sql = "select * from employee where empcode='" & txtuname.Text & "' and password='" & txtupass.Text & "'"
If rs.State = 1 Then
rs.Close()
rs.Open(sql, conn)
If rs.EOF = False Then
MDIMain.MasterToolStripMenuItem.Visible = False
MDIMain.EmployeeToolStripMenuItem.Visible = False
MDIMain.SearchToolStripMenuItem.Visible = False
MDIMain.LeaveToolStripMenuItem.Visible = False
MDIMain.EarnToolStripMenuItem.Visible = False
MDIMain.DeductionToolStripMenuItem.Visible = False
MDIMain.events.Visible = False
empid = txtuname.Text
' MsgBox("login sucess")
MDIMain.Show()
Me.Hide()
End If
Else
sql = "select * from login where utypt='" & cmbutype.Text & "' and uname='" & txtuname.Text & "'"
If rs.State = 1 Then
rs.Close()
rs.Open(sql, conn)
If rs.EOF = False Then
sql = "select * from login where utypt='" & cmbutype.Text & "' and uname='" & txtuname.Text & "' and upass='" & txtupass.Text & "'"
If rs.State = 1 Then
rs.Close()
rs.Open(sql, conn)
If rs.EOF = False Then
' MsgBox("login sucess")
MDIMain.Show()
Me.Hide()
Else
MsgBox("Incorrect password ")
End If
Else
MsgBox("login failed")
End If
End If
End Sub
私は 'ADODB'
Gah。 SQLの注入セキュリティホールは、それは私たちを燃やす! –
また、Option InferまたはOption Strict –
をオンにしてください。 – Newbee