Last post Dec 31, 2014 11:09 AM by JoyceW
Dec 30, 2014 12:49 PM|coollibran|LINK
I have this query where i have used inner join.I want to display data from two tables based on matching condition of PID.I am able to display data from one table.Hw can i display data from second table using this procedure only.please suggest or the other
way of writing the query .
/****** Object: StoredProcedure [dbo].[sp_SJoin] Script Date: 12/30/2014 22:25:10 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER PROCEDURE [dbo].[sp_SJoin]
SELECT * FROM [tblP]
INNER JOIN [tblP1]
([tblP].PID = [tblP1].PID
WHERE ([tblP].PID like '%' + @SearchString + '%' OR [tblP].NO like '%' + @SearchString + '%' OR [tblP].Name like '%' + @SearchString + '%' OR [tblP].State like '%' + @SearchString + '%' OR [tblP].District like '%' + @SearchString + '%')
Dec 30, 2014 01:45 PM|JoyceW|LINK
I don't understand the problem. The query will show the columns of both tables.
Can you explain what you want a little better?
Dec 30, 2014 02:09 PM|limno|LINK
List out the columns you need and don't use * in your production code.
You have a coding error by not defining the size of the varchar for the parameter (the parameter value will be truncated to 1).
Dec 31, 2014 10:59 AM|coollibran|LINK
I actually want to display data from two tables which are tblP and tblP1 on a single aspx page.i have used inner join as mentioned in previous post.
Dec 31, 2014 11:09 AM|JoyceW|LINK
I'm still not sure exactly what you want to accomplish but for a very basic page that displays the results of your query you can follow these steps.
Add a sqldatasource to your page.
Configure the data source by adding your connection string. Then, in the Configure The Select Statement screen, Select "Specify a custom SQL statement or stored procedure.
In the next screen you will be given a box to enter the select statement. Put your query with the inner join in that box. Click the next button and on the screen the follows you can test your query to make sure you are getting the results you want.
Once you have you have that done you can put a gridview on your form. Set the gridview's datasource to the sqldatasource you created. Run the page and you should see the results of your query in a table on the page.
Once you've accomplished that you can ask more specific questions.