Reputation: 75
I try to search records in asp.net for this first I create stored procedure:
ALTER procedure [dbo].[spsearchdocuments]
@Name nvarchar(50)
as
SELECT
dbo.DocumentInfo.DocID as DocumentID,
dbo.DocumentInfo.DocName as DocumentName,
dbo.DocumentInfo.Uploadfile as FileUploaded,
dbo.DocumentInfo.UploadedDate as UploadedDate,
dbo.Department.DepType as Department,
dbo.DocType.DocType as Document,
dbo.DocumentInfo.UploadedBy as UploadedBy,
dbo.Approval.AppoveBy, dbo.ApproveType.ApproveType as Status
FROM
dbo.DocumentInfo
INNER JOIN
dbo.Approval ON dbo.DocumentInfo.DocID = dbo.Approval.DocID
INNER JOIN
dbo.ApproveType ON dbo.Approval.ApproveID = dbo.ApproveType.ApproveID
INNER JOIN
dbo.Department ON dbo.DocumentInfo.DepID = dbo.Department.DepID
INNER JOIN
dbo.DocType ON dbo.DocumentInfo.DocTypeID = dbo.DocType.DocTypeID
WHERE
[DocName] like @Name+'%'
and then when I call this procedure in a function like this
public DataTable searchdcouments(string Name )
{
return db.ExecuteDataSet("spsearchdocuments", new object[] { Name }).Tables[0];
}
and when I call this function in .aspx form behind search button like this
protected void Btn_submits_Click(object sender, EventArgs e)
{
Repeater4.DataSource = sear.searchdcouments(searz.Text);
Repeater4.DataBind();
}
and when I debug my project and write keyword then it not show me any record where record exist in database
Have a look below pictures
When I enter keyword
and when I click on search button it shows me like this
Upvotes: 0
Views: 2406
Reputation: 997
Looks like you are mistyping your keyword. It's "ERP SYSTEM" in DB, and "erpssystem" in the search box
Edit after your comment
"like google" means that you have to run your select every time search string changes, e.g. user types/deletes a letter.
To do this take your searz object and add a handler to it's "value changed" event.
second edit
Assuming it is a TextBox and you are using VisualStudio, open searz's properties and find TextChanged
event. Double-clicking it will create TextChanged event handler, that you'd fill in like so:
protected void searz_TextChanged(object sender, EventArgs e)
{
Repeater4.DataSource = sear.searchdcouments(searz.Text);
Repeater4.DataBind();
}
Upvotes: 1