Click here to Skip to main content
16,011,815 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi i have two tables the first have many fields including department_id.The other one have department_id and department description i want to display in gridview first table fields including department description related with department_id

Query:
SQL
SelectCommand="SELECT [report_no], [datesubmision], [complainee_name], [complainee_surname], [complainee_idnumber], [complainee_tel], [policynumber], [claimnumber], [typeofperson],[department_id],[status_id], [id] FROM [accusationform]"

Please help me
Posted
Updated 13-Nov-13 17:02pm
v2
Comments
♥…ЯҠ…♥ 13-Nov-13 8:47am    
Do you want to display department_name in place of department_id in grid view,dont you?
nikolas_ar 13-Nov-13 8:48am    
Yes
nikolas_ar 13-Nov-13 8:49am    
Thanks for your quick reply
♥…ЯҠ…♥ 13-Nov-13 8:49am    
Next time be more specific in your question....Now update your table schema and query that you used to get the record
nikolas_ar 13-Nov-13 8:57am    
Sorry about that

1 solution

Hi Nikolas,

Here is the query you can make use of
SQL
SELECT [acussfrm.report_no], 
       [acussfrm.datesubmision], 
       [acussfrm.complainee_name], 
       [acussfrm.complainee_surname], 
       [acussfrm.complainee_idnumber], 
       [acussfrm.complainee_tel], 
       [acussfrm.policynumber], 
       [acussfrm.claimnumber], 
       [acussfrm.typeofperson], 
       [secfrm.department_name], --Here department name is replaced 
       [acussfrm.status_id], 
       [acussfrm.id] 
FROM   [accusationform] AS acussfrm, 
       [secondform] AS secfrm -- Rename secondform to your second table name
WHERE  [acussfrm.department_id] = [secfrm.department_id] --Here is the condition that reads the common data from two tables with having department_id as common id.

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
Comments
nikolas_ar 14-Nov-13 4:03am    
Hi thanks for helping me i used the query but i get error conversion failed when converting the varchar value 'management' to data type int
Management is the first item in my table
♥…ЯҠ…♥ 14-Nov-13 4:28am    
can you paste the query that you tried?
nikolas_ar 14-Nov-13 4:31am    
select report_no , datesubmision , complainee_name,complainee_surname,typeofperson,department.description from accusationform ,department where department_id = department.description
♥…ЯҠ…♥ 14-Nov-13 4:33am    
what do you get in department.description? i think you comparing varchar with int value in where condition.. rectify it and it will work as expected

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900