Dim cn As New SqlConnection(cnstr) : cn.Close()
Using cn As New SqlConnection(cnstr) : cn.Close() 'Close は呼んでも呼ばなくても良い End Using
Dim sqlQuery As String = "SELECT Password, 権限 FROM [dbo].[Table] WHERE ID = @Id" Using cmd As New SqlCommand(sqlQuery, cn) cmd.Parameters.Add("@Id", SqlDbType.VarChar, 8).Value = Id.Text Using rd = cmd.ExecuteReader() ' : End Using End Using