C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

Retrive Data from database in aspx file using Stored Procedure and class file


Posted Date: 12 Dec 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: rajesh singhMember Level: Gold    
Rating: 1 out of 5Points: 5



Step1: Create SP in database



-- =============================================
-- Author:rajesh
-- Create date: 6th Nov 2008
-- Description: this SP is to find the keyword used to do search.
-- =============================================
IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id('JAU_SP_Getkeyword'))
DROP PROCEDURE JAU_SP_Getkeyword
GO

CREATE PROCEDURE JAU_SP_Getkeyword
(
@piMemberID INT
)
AS
BEGIN
select sTitle from JAU_Favouritesearch Group by sTitle
END
GO


Step2: call SP from class file



(1)Create function in class file

'function made by rajesh for search
Public Function findkeyword() As DataSet
Dim objDBManager As New commonlib.Common.DBManager(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Dim keywordresult As New DataSet
Dim sSQL As String = "JAU_SP_Getkeyword"
Dim p(0) As SqlParameter
Try
p(0) = New SqlParameter("@piMemberID", _iMemberID)
keywordresult = Objdbmanager.ExecuteDataSet(CommandType.StoredProcedure, sSQL, p)
Dim str As String = Objdbmanager.ErrorMessage
Return keywordresult
Catch ex As Exception
ex = Nothing
End Try
End Function

(2)Create property in class file

Protected _iMemberID As Integer

Public Property memberID() As Integer
Get
Return _iMemberID
End Get
Set(ByVal value As Integer)
_iMemberID = value
End Set
End Property


Step3: call function defined in class file in aspx file



Dim objsearch As New Search /*Search here is class file name*/
/* By Below code you can use the data form the database */
'code done by rajesh to find keyword
Dim dskeyword As DataSet
dskeyword = objsearch.findkeyword()
Dim keywordtitle As String = Trim(Request.QueryString("Text"))
For i As Integer = 0 To dskeyword.Tables(0).Rows.Count - 1
Dim str As String = Trim(dskeyword.Tables(0).Rows(i).Item(0))
If str = keywordtitle Then
linkfav.Visible = False
End If
Next


Attachments

  • Retrive Data from database in aspx file using SP and class file (23837-12349-Call Data from database in aspx file using SP and class file (function).doc)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Simple search engine code  .  Retrive Data from database in aspx file using SP and class file  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: birthday comparing todays date
    Previous Resource: Popup window in ASP.NET
    Return to Discussion Resource Index
    Post New Resource
    Category: ASP.NET WebForms


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use