Advertisement

01.08.2008 at 05:49AM PST, ID: 23066423
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Linq to SQL - iterating through results and handling the 'no results' situation
Tags: linq, results, sql
Hi,

I am using Linq to SQL and have created various objects using the OR Mapping tool.
I have set up the following query:

Dim MfrCode() As String = From M In Db.ManufacturingCompanies _
                          Where M.MANUFACTURING_COMP_CODE = Convert.ToString(reader.Item("MFRCode")) _
                          Select M.MANUFACTURING_COMP_CODE

This should either return a single record or no data.
I now want to access the data (if any) in the returned object or handle the situation where this is no data.

If data is returned, I can see it using ObjectDumper but cannot seem to find a way to access the returned values using a For Each type construct.  If no data is returned I simply get an invalidcast exception. I have tried to Tolist / ToArray functions but these do not seem to help!

Is there a simple way to access the data from a Linq query and consistently identify when the query returns no results?
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: alan_ITG
Solution Provided By: Ceiled
Participating Experts: 1
Solution Grade: A
Views: 160
Translate:
Loading Advertisement...
01.08.2008 at 11:08AM PST, ID: 20611568

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.09.2008 at 03:12AM PST, ID: 20617048

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.09.2008 at 09:09AM PST, ID: 20619988

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.10.2008 at 01:03AM PST, ID: 20625835

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.10.2008 at 01:14AM PST, ID: 20625883

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.10.2008 at 01:32AM PST, ID: 20625963

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.10.2008 at 08:56AM PST, ID: 20628727

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.11.2008 at 01:23AM PST, ID: 20635031

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
01.08.2008 at 11:08AM PST, ID: 20611568
Where is that reader object coming from? It sounds like what you're trying to do is determine if a manufacturer's code you retrieved from somewhere else is in your database. The query you gave should return an empty list if nothing matches, so I don't think that's the problem. I suspect that what's actually happening is that the MFRCode item from the query you executed earlier is coming back as DbNull, which is causing your Convert.ToString() call to fail. Try wrapping the query in an if (!reader.IsDbNull("MFRCode")) check and see if that helps. If the code you're looking for is null, then you probably want to treat that as the same as the query not returning any data.
 
01.09.2008 at 03:12AM PST, ID: 20617048
Ceiled,

Thanks for your comments.  I have rewritten my code considering your points and have certainly moved forwards by identifying if the MFRCode is Null prior to running the Linq query and handling this situation.
However, I still do not have an elegant way to identify if the Linq query returns records or not.  I can iterate using a For Each loop to count the records to determine if something has been returned, but this seems a little clumsy.  

I have now set up a console app to test this piece of code using Northwind as follows:-

Imports System.Data.Linq
Module Module1

    Sub Main()
        Dim db As New NorthWindDataContext

        Dim Emps = From Employee In db.Employees _
                   Select Employee

        Debug.Print(Emps.Count)

        For Each emp In Emps
            Console.WriteLine("Code={0}, Name={1}", emp.EmployeeID, emp.FirstName)
        Next

        Console.ReadLine()
    End Sub

End Module

So it seems to be possible to test for the number of records returned by the Linq query in the console example using the count property.  However, if I port the code to my windows application, the equivalent statement to Debug.print(Emps.count ) statement does not work, indeed there is no count property on the object.  

Any ideas why this occurs?
regards,

Alan
 
01.09.2008 at 09:09AM PST, ID: 20619988
I assume you're importing the System.Data.Linq namespace in your Windows application? This is necessary in order to bring in the Count() extension method, among others...if you're doing that, Count() should be available. Are you simply not seeing it in IntelliSense, or are you actually getting an error when you try to use it? Can you post as much of the code in the Windows application as is needed to reproduce the problem?
 
01.10.2008 at 01:03AM PST, ID: 20625835

Ceiled,

as requested, below is the full code for the section of the app that I am converting to use Linq.  As you will see this sub uses both Linq and ADO to access data from two different databases.
The problem I am currently having is that even though system.data.linq is imported, the option to use Mfrs.count does not appear in intellisense where I would use it (indicated below). I have also highlighted another issue which may be causing problems.

Imports System.Data.Linq


Module LinqModule

    Public Sub ValidateStandardSKUs()
        Dim sSQL As String
        Dim cConMDM As New Data.SqlClient.SqlConnection
        Dim cCMD As New Data.SqlClient.SqlCommand
        Dim reader As Data.SqlClient.SqlDataReader
        Dim SSKUCount As Long = 0
        Dim MFR_Valid As Boolean
        Dim TMO_Valid As Boolean
        Dim MktConst_Valid As Boolean
        Dim PType_Valid As Boolean
        Dim Db As New BusRulesDataContext

        Try
            With cConMDM
                .ConnectionString = My.Settings.cUsrConMDM
                .Open()
            End With
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Connection Error in ValidateStandardSKUs", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
            Exit Sub
        End Try

        'Get Count of Standard SKU's
        sSQL = "SELECT DISTINCT COUNT(STANDARD_SKU_CODE) AS SSKUCode" & vbLf
        sSQL = sSQL & "FROM         ATT_STANDARD_SKU AS p" & vbLf
        sSQL = sSQL & "WHERE     (END_DATE > GETDATE()) AND (START_DATE <= GETDATE()) AND (BE_ID <> '$NOOID')"
        Try
            With cCMD
                .CommandTimeout = 0
                .CommandType = Data.CommandType.Text
                .Connection = cConMDM
                .CommandText = sSQL
                reader = .ExecuteReader
            End With
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Command Error in ValidateStandardSKUs", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
            Exit Sub
        End Try

        If reader.HasRows Then
            reader.Read()
            SSKUCount = CLng(reader.Item(0))
        End If
        reader.Close()

        'Select Standard SKU and the attributes relevant to Standard SKU
        sSQL = "Select DISTINCT" & vbLf
        sSQL = sSQL & "p.STANDARD_SKU_CODE AS SSKUCode, p.STANDARD_SKU_NAME AS SSKUName, p.STANDARD_SKU_SHORT_NAME AS SSKUShortName, " & vbLf
        sSQL = sSQL & "p.PROD_GRP_CODE AS PGCode, p.PROD_GRP_NAME AS PGName, p.MKT_CONSTRAINT_CODE AS MConstCode, " & vbLf
        sSQL = sSQL & "p.MANUFACTURING_COMP_CODE AS MfrCode, p.TRADEMARK_OWNER_CODE AS TMOCode, p.PROD_TYPE_CODE AS PTypeCode" & vbLf
        sSQL = sSQL & "FROM         dbo.MAP_LOCAL_SKU_DIM AS L INNER JOIN" & vbLf
        sSQL = sSQL & "dbo.MAP_PRODUCT_DIM AS p ON p.BE_ID = L.L_SKU_RETAIL_SKU AND p.BE_ID = p.RETAIL_SKU AND p.START_DATE <= GETDATE() AND " & vbLf
        sSQL = sSQL & "p.END_DATE > GETDATE() AND p.BE_ID <> '$NOOID'" & vbLf
        sSQL = sSQL & "WHERE     (L.START_DATE <= GETDATE()) AND (L.END_DATE > GETDATE()) AND (L.BE_ID <> '$NOOID') AND (L.BE_ID = L.LOCAL_SKU)" & vbLf
        'sSQL = sSQL & "AND (p.MANUFACTURING_COMP_CODE is null)" & vbLf
        sSQL = sSQL & "ORDER BY p.PROD_GRP_CODE, p.STANDARD_SKU_CODE"

        'For each record in the dataset
        'validate if the attribute value is valid according to the business rules established
        'if valid then List record with OK
        'if not valid then list record with validation errors
        UpdateStatus("Retrieving Standard SKU Records. Please wait...")
        Try
            With cCMD
                .CommandTimeout = 0
                .CommandType = Data.CommandType.Text
                .Connection = cConMDM
                .CommandText = sSQL
                reader = .ExecuteReader
            End With
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Command Error in ValidateStandardSKUs", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
            Exit Sub
        End Try

        If reader.HasRows Then
            Dim recCount As Long = 0
            Dim errCount As Long = 0
            While reader.Read
                recCount = recCount + 1

                'Validate Manufacturing Company

                If IsDBNull(reader.Item("MFRCode")) Then
                    WritetoDGV(reader.Item("PGName"), reader.Item("SSKUCode"), reader.Item("SSKUShortName"), "Error: Manufacturing Co Code 'NULL' is invalid for this Standard SKU")
                    errCount = errCount + 1
                    MFR_Valid = False
                Else

                    Dim Mfrs = From Manufacturers In Db.ManufacturingCompanies _
                               Where Manufacturers.MANUFACTURING_COMP_CODE = Convert.ToString(reader.Item("MFRCode")) _
                               Select Manufacturers.MANUFACTURING_COMP_CODE

                    Dim itemCount As Integer = 0

                    For Each Mfrs In Mfrs                    '<<-- is this a problem?  If I change to For Each Mfr in MFrs
                                                                          '        I get an undeclared variable error.
                        itemCount = itemCount + 1
                    Next

''' AT THIS POINT I WOULD USE
'' If Mfrs.count = 0 then instead of the itemcount generated by the For Each loop above

                    If itemCount = 0 Then
                        'no records were returned so record error
                        WritetoDGV(reader.Item("PGName"), reader.Item("SSKUCode"), reader.Item("SSKUShortName"), "Error: Manufacturing Co Code '" & Convert.ToString(reader.Item("MFRCode")) & "' is invalid for this Standard SKU")
                        errCount = errCount + 1
                        MFR_Valid = False
                    Else
                        'a record was returned so no error
                        MFR_Valid = True
                    End If

                End If

                'Only show valid records if user wants them
                If frmAttributeValidation.rbAllRecs.Checked Then
                    If MFR_Valid Then
                        WritetoDGV(reader.Item("PGName"), reader.Item("SSKUCode"), reader.Item("SSKUShortName"), "Validated OK.")
                    End If
                End If

                UpdateStatus("Validating record " & recCount & " of " & SSKUCount & ". " & errCount & " errors found.")

            End While

            UpdateStatus(errCount & " errors found. Process completed.")

        Else

            MessageBox.Show("No records returned from MDM.", "ValidateStandardSKUts", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
            Exit Sub
        End If

        reader.Close()
        cConMDM.Close()
        cConMDM.Dispose()

    End Sub

End Module

Strangely enough, I have just copied the moduel to a new project and this has resolved all the issues. So I am wondering if this proble has something to do with the fact this is a Vb2005 project converted to VB2008?

Regards,


Alan
 
01.10.2008 at 01:14AM PST, ID: 20625883
Interesting...the only thing I can think of is that perhaps your old project had Option Strict or Option Explicit enabled, and that was somehow getting in the way? I just did a quick test, and VB 9 handles untyped variables by inferring a type from the value you set it to, so I don't know what the deal. The Count() method should be available there, and it was in my test. Could you perhaps post the contents of your .vbproj file?
 
01.10.2008 at 01:32AM PST, ID: 20625963
Ceiled,

Below is the vbproj file info as requested.  I checked the Option Explicit setting and it was set to ON. Whan I changed this, the issue where For Each MFR in MFRS was resolved but I still do not get the .Count property on MFRS either in intellisense nor when just running the code.

Many thanks for your continued help!

Regards,   Alan

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.21022</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{4651F138-134E-46DA-AEF9-A04ED9C63232}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <StartupObject>MDM_BusRules.My.MyApplication</StartupObject>
    <RootNamespace>MDM_BusRules</RootNamespace>
    <AssemblyName>MDM_BusRules</AssemblyName>
    <MyType>WindowsForms</MyType>
    <ManifestCertificateThumbprint>F234C2F11B696B4A2D3F2ADE9BE0D80CF4DF061B</ManifestCertificateThumbprint>
    <ManifestKeyFile>MDM_BusRules_1_TemporaryKey.pfx</ManifestKeyFile>
    <GenerateManifests>true</GenerateManifests>
    <SignManifests>true</SignManifests>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <SignAssembly>true</SignAssembly>
    <AssemblyOriginatorKeyFile>MDM_BusRules_1_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <OldToolsVersion>2.0</OldToolsVersion>
    <PublishUrl>C:\Publish\BusRules\</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <CreateWebPageOnPublish>false</CreateWebPageOnPublish>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <OptionExplicit>On</OptionExplicit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>MDM_BusRules.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DocumentationFile>MDM_BusRules.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="DataGridViewColumns, Version=1.3.2.0, Culture=neutral, PublicKeyToken=26596b3a8d7c8940, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\DataGridViewColumns.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
    <Reference Include="Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
    <Reference Include="System" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data" />
    <Reference Include="System.Data.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Drawing" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Linq" />
    <Import Include="System.Windows.Forms" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="ApplicationEvents.vb" />
    <Compile Include="BulkUpdate.vb" />
    <Compile Include="BulkUpdate_PH.vb" />
    <Compile Include="BusRules.designer.vb">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>BusRules.dbml</DependentUpon>
    </Compile>
    <Compile Include="BusRules.vb">
      <DependentUpon>BusRules.dbml</DependentUpon>
    </Compile>
    <Compile Include="Enums.vb" />
    <Compile Include="frmAddAttributes.Designer.vb">
      <DependentUpon>frmAddAttributes.vb</DependentUpon>
    </Compile>
    <Compile Include="frmAddAttributes.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmBSF.Designer.vb">
      <DependentUpon>frmBSF.vb</DependentUpon>
    </Compile>
    <Compile Include="frmBSF.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmBVBN.Designer.vb">
      <DependentUpon>frmBVBN.vb</DependentUpon>
    </Compile>
    <Compile Include="frmBVBN.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmDuplicates.Designer.vb">
      <DependentUpon>frmDuplicates.vb</DependentUpon>
    </Compile>
    <Compile Include="frmDuplicates.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmMktHierarchy.Designer.vb">
      <DependentUpon>frmMktHierarchy.vb</DependentUpon>
    </Compile>
    <Compile Include="frmMktHierarchy.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmAddBV.Designer.vb">
      <DependentUpon>frmAddBV.vb</DependentUpon>
    </Compile>
    <Compile Include="frmAddBV.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmAddProduct.Designer.vb">
      <DependentUpon>frmAddProduct.vb</DependentUpon>
    </Compile>
    <Compile Include="frmAddProduct.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmAttributeValidation.Designer.vb">
      <DependentUpon>frmAttributeValidation.vb</DependentUpon>
    </Compile>
    <Compile Include="frmAttributeValidation.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmBusRules.Designer.vb">
      <DependentUpon>frmBusRules.vb</DependentUpon>
    </Compile>
    <Compile Include="frmBusRules.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmProdHierarchy.Designer.vb">
      <DependentUpon>frmProdHierarchy.vb</DependentUpon>
    </Compile>
    <Compile Include="frmProdHierarchy.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmMDI.Designer.vb">
      <DependentUpon>frmMDI.vb</DependentUpon>
    </Compile>
    <Compile Include="frmMDI.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmNameValidation.Designer.vb">
      <DependentUpon>frmNameValidation.vb</DependentUpon>
    </Compile>
    <Compile Include="frmNameValidation.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmPrint.Designer.vb">
      <DependentUpon>frmPrint.vb</DependentUpon>
    </Compile>
    <Compile Include="frmPrint.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmSMO.designer.vb">
      <DependentUpon>frmSMO.vb</DependentUpon>
    </Compile>
    <Compile Include="frmSMO.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmMain.vb">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmMain.Designer.vb">
      <DependentUpon>frmMain.vb</DependentUpon>
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="LinqModule.vb" />
    <Compile Include="MDM_BusRulesDataSet.Designer.vb">
      <DependentUpon>MDM_BusRulesDataSet.xsd</DependentUpon>
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
    </Compile>
    <Compile Include="MDM_BusRulesDataSet.vb">
      <DependentUpon>MDM_BusRulesDataSet.xsd</DependentUpon>
    </Compile>
    <Compile Include="modMain.vb" />
    <Compile Include="My Project\AssemblyInfo.vb" />
    <Compile Include="My Project\Application.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Application.myapp</DependentUpon>
    </Compile>
    <Compile Include="My Project\Resources.Designer.vb">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="My Project\Settings.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <Compile Include="NameValidation.vb" />
    <Compile Include="AttributeValidation.vb" />
    <Compile Include="ObjectDumper.vb" />
    <Compile Include="xlModule.vb" />
  </ItemGroup>
  <ItemGroup>
    <None Include="BusRules.dbml.layout">
      <DependentUpon>BusRules.dbml</DependentUpon>
    </None>
    <EmbeddedResource Include="frmAddAttributes.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmAddAttributes.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmBSF.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmBSF.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmBVBN.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmBVBN.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmDuplicates.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmDuplicates.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmMktHierarchy.resx">
      <DependentUpon>frmMktHierarchy.vb</DependentUpon>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <EmbeddedResource Include="frmAddBV.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmAddBV.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmAddProduct.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmAddProduct.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmAttributeValidation.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmAttributeValidation.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmBusRules.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmBusRules.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmProdHierarchy.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmProdHierarchy.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmMDI.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmMDI.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmNameValidation.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmNameValidation.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmPrint.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmPrint.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="frmSMO.resx">
      <DependentUpon>frmSMO.vb</DependentUpon>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <EmbeddedResource Include="frmMain.resx">
      <SubType>Designer</SubType>
      <DependentUpon>frmMain.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="My Project\Resources.resx">
      <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <SubType>Designer</SubType>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
    <None Include="MDM_BusRulesDataSet.xsc">
      <DependentUpon>MDM_BusRulesDataSet.xsd</DependentUpon>
    </None>
    <None Include="MDM_BusRulesDataSet.xsd">
      <SubType>Designer</SubType>
      <Generator>MSDataSetGenerator</Generator>
      <LastGenOutput>MDM_BusRulesDataSet.Designer.vb</LastGenOutput>
    </None>
    <None Include="MDM_BusRulesDataSet.xss">
      <DependentUpon>MDM_BusRulesDataSet.xsd</DependentUpon>
    </None>
    <None Include="MDM_BusRules_1_TemporaryKey.pfx" />
    <None Include="MDM_BusRules_TemporaryKey.pfx" />
    <None Include="My Project\Application.myapp">
      <Generator>MyApplicationCodeGenerator</Generator>
      <LastGenOutput>Application.Designer.vb</LastGenOutput>
    </None>
    <None Include="My Project\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <CustomToolNamespace>My</CustomToolNamespace>
      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
    </None>
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
      <Visible>False</Visible>
      <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\sortedAscending.gif" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Resources\UpArrow_Red.bmp" />
  </ItemGroup>
  <ItemGroup>
    <None Include="BusRules.dbml">
      <Generator>MSLinqToSQLGenerator</Generator>
      <LastGenOutput>BusRules.designer.vb</LastGenOutput>
      <SubType>Designer</SubType>
    </None>
    <None Include="Resources\DownArrow_Red.bmp" />
  </ItemGroup>
  <ItemGroup>
    <COMReference Include="Excel">
      <Guid>{00020813-0000-0000-C000-000000000046}</Guid>
      <VersionMajor>1</VersionMajor>
      <VersionMinor>5</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
    </COMReference>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="My Project\DataSources\" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
 
01.10.2008 at 08:56AM PST, ID: 20628727
Aha! I installed VB support and took a look, and I think I see where the problem is. They've added a new project-level option since I last worked with VB: Option Infer. It determines whether untyped variables get typed as "Object" or as the value of their initialization expression. If you have Option Infer turned off, then the type of "Mfrs" will be Object because you don't have an As clause in the definition, so of course IntelliSense won't be able to show you the Count() method.

Furthermore, even with Option Strict turned off, trying to use Count() will give you an error because it's an extension method, and VB's late-binding support apparently (and understandably) doesn't work with those. If you turn on Option Infer in your original project (I bet imported projects have it turned off, to preserve the original behavior), this should start working.

Oh, and to solve the For Each thing without turning off Option Strict (and I very strongly recommend enabling both Option Strict and Option Explicit if at all possible), you need to either specify a type by saying "For Each Mfr As Integer In Mfrs", or declare a new variable explicitly above it -- as far as I can tell, there's no way to write a strongly-typed For Each loop without explicitly defining the type of the enumeration variable.

Hope this helps!
Accepted Solution
 
01.11.2008 at 01:23AM PST, ID: 20635031

Ceiled,

you nailed it!  Many thanks for your help.

Regards,


Alan
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628