Imports System.Data.SqlClient Public Class FmLogin Const ConnectString As String = "Data Source=user;Initial Catalog=データベースシステム;Integrated Security=True" Private Sub btnGo_Click(sender As System.Object, e As System.EventArgs) Handles btnGo.Click If CheckUser(TextBox1.Text.Trim, TextBox2.Text.Trim) Then Me.Hide() Dim Main As New fmmain Main.ShowDialog(Me) Me.Show() Me.Close() Else MsgBox("ID,パスワードが一致しません") End If End Sub Private Function CheckUser(id As String, pass As String) As Boolean Dim RESULT As Integer = 0 Dim SQL As String = "SELECT COUNT(ユーザーID) FROM ユーザー情報" _ & " WHERE ユーザーID='" & id & "' AND パスワード='" & pass & "'" Using conn As New SqlConnection(ConnectString) Dim CMD As New SqlCommand(SQL, conn) Try conn.Open() RESULT = Convert.ToInt32(CMD.ExecuteScalar()) Catch ex As Exception MsgBox(ex.Message) End Try End Using Return RESULT <> 0 End Function Private Sub btnQuit_Click(sender As System.Object, e As System.EventArgs) Handles btnQuit.Click Me.Close() End Sub End Class