I have an issue in Visual Web Developer 2010 that I need help with.
The code below is a Gridview Sql query where I'm extracting PART_NUMBER from various tables. I would like to add the table name in a separate field named Comp Type. When I use Query Builder in Configure Data Source and run Execute Query the results are what I want. However when I run the actual program the Comp Type column is empty.
The end result should appear as follows:
PART_NUMBER Comp Type
010-0075-06 Resistors (or Capacitors, etc.)
Sql query:
SELECT PART_NUMBER, ('Capacitors') AS [Comp Type] FROM Capacitors EXCEPT SELECT PART_NUMBER, ('Capacitors') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Connector') AS [Comp Type] FROM Connectors EXCEPT SELECT PART_NUMBER, ('Connectors') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Diodes') AS [Comp Type] FROM Diodes EXCEPT SELECT PART_NUMBER, ('Diodes') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('ICs') AS [Comp Type] FROM ICs EXCEPT SELECT PART_NUMBER, ('ICs') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Inductors') AS [Comp Type] FROM Inductors EXCEPT SELECT PART_NUMBER, ('Inductors') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Misc') AS [Comp Type] FROM Misc EXCEPT SELECT PART_NUMBER, ('Misc') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Relays') AS [Comp Type] FROM Relays EXCEPT SELECT PART_NUMBER, ('Relays') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Resistors') AS [Comp Type] FROM Resistors EXCEPT SELECT PART_NUMBER, ('Resistors') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Switches') AS [Comp Type] FROM Switches EXCEPT SELECT PART_NUMBER, ('Switches') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Transformers') AS [Comp Type] FROM Transformers EXCEPT SELECT PART_NUMBER, ('Transformers') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Transistors') AS [Comp Type] FROM Transistors EXCEPT SELECT PART_NUMBER, ('Transistors') AS [Comp Type] FROM [CIS Manufacturer Parts] UNION SELECT PART_NUMBER, ('Crystals and Oscillators') AS [Comp Type] FROM [Crystals and Oscillators] EXCEPT SELECT PART_NUMBER, ('Crystals and Oscillators') AS [Comp Type] FROM [CIS Manufacturer Parts] ORDER BY PART_NUMBER
The asp portion is below and I suspect I'm missing something:
<asp:TemplateField><HeaderTemplate> Comp Type</HeaderTemplate><ItemTemplate></ItemTemplate></asp:TemplateField>
I have a separate table (CIS Manufacturer Parts) that contains manufacturer data for the above parts. Multiple manufacturer rows can exist. The connection between tables in the PART_NUMBER field. What I would like to do is make this query add the table name to the gridview output listing only parts without manufacturer data and the table they can be found in.
This is a lot for a newbie so I will appreciate any help, thanks!