Hi Ihave two table in databse:
1-VideoL
2-Software
I want it search in name column's of both table so I wrote below StoreProcedur:
ALTER procedure [dbo].[GetCustomersPageWiseSoft]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
,@search nvarchar(100)
,@SecondClass nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY [Date] desc
)AS RowNumber
,[ID]
,[Name]
,[Image]
,[Date]
,[Code]
,FirstClass
,SecondClass
,substring([Description],0,700)+'...' As Description
,Quality
,[Time]
,Hajim
,Language
,UrlName
INTO #Results1
FROM [VideoL]
where (Name like '%'+@search+'%' or @search='')and(SecondClass=@SecondClass)
SELECT @RecordCount = COUNT(*)
FROM #Results1
SELECT * FROM #Results1
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results1
SELECT ROW_NUMBER() OVER
(
ORDER BY [Date] desc
)AS RowNumber
,[ID]
,[Name]
,[Image]
,[Date]
,[Code]
,FirstClass
,SecondClass
,substring([Description],0,700)+'...' As Description
,UrlName
INTO #Results
FROM [SoftWare]
where (Name like '%'+@search+'%' or @search='')and(SecondClass=@SecondClass)
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
it will show resualt in datalist:
private void GetCustomersPageWise(int pageIndex)
{
//string Secondclass = Request.QueryString["Secondclass"].ToString();
string Secondclass = this.Page.RouteData.Values["Secondclass"].ToString();
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand cmd = General.GetCommand("GetCustomersPageWiseSoft", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
cmd.Parameters.AddWithValue("@PageSize", PageSize);
cmd.Parameters.AddWithValue("@Search", TxtsearchI.Text);
cmd.Parameters.AddWithValue("@SecondClass", Secondclass);
cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4);
cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
conn.Open();
SqlDataReader idr = cmd.ExecuteReader();
if (idr.HasRows)
{
DLSoft.DataSource = idr;
DLSoft.DataBind();
rptPager.Visible = !(rptPager2.Visible = false);
}
idr.Close();
this.PopulatePager(Convert.ToInt32(cmd.Parameters["@RecordCount"].Value), pageIndex);
}
}
}
now problem is that it just show first tabel(VideoL) data in datalist I mean it doesn't show SoftWare Table (second table) data in datalist.
My tables in database don't have any common column I mean tables are totaly different ...
What should I do?
Best Regards
Neda