GetRecord method 2.0 SQL 2005 Server Find record with where clause

Posted on 2008-11-03
Last Modified: 2012-05-05
I am using I have a master-Detail page where the master displays an account record.
the detail displays all transactions related to that specific account.
The particular transactions are subject to approval by users with authority to approve each transaction.
I have  image buttons that default to visible = false in the detail row.
The image button links to  a page that allows the logged in user to approve the transaction.

i need to make the imagebutton visible=true  based on a function that checks the logged in users
record to check if the logged in user has permission to approve a transaction.

I need a function that grabs the logged-in user id and gets the users record from a table that has the
user information that determines if the logged in user has permissions to approve the transaction.
If so then I need to make that imagebutton visible.on display.

I have the code that grabs the logged in userID from the session.
"Dim userID As String = Me.Page.SystemUtils.GetLoginId()"

I need the Logged -in userID and the organizationID to tell the function what record to retrieve.
The OrganizationID is passed to the master page through a querystring =?Organization

The table I have to get the user record from is titled" IndividualsinOrganizations"

Table  IndividualsinOrganizations
FieldName      Datatype     Filter or conditional
IndividualID      integer      This should correspond with the UsrID =logged in userID
OrganizationID Integer      This should correspond to the OrganizationID in the  current Record.
Active               bit             =true
StartDate          smallDatetime   =< currentDate
EndDate          SmallDatetime      => currentDate
CheckApproval   bit                   =True

I am told I can use a GetRecord(s) method to retrieve the record based on the logged in UserID and organizationID.
Once i retreive the record I can use the where clause to determine if the logged user has rights to approve the transaction therefore I can make the image button visible
It has also been suggested that I put this function in the DataBind method of the recordControlRow.

How can I write this code so it works?

Question by:tommynations
    LVL 44

    Expert Comment

    Is this for a WinForm application, or ASP.NET Web application?

    Author Comment

    This is a application
    Using and sqlserver 2005
    LVL 44

    Expert Comment

    There is a GetRows method, but it only applies to an ADO recordset object, which I doubt you want to be using with ASP.NET and VB.NET - you would be much better off learning about using DataTables and DataAdapters to retrieve data from a SQL Server Database.
    You want to make use of ADO.NET - which is not the same as classic ADO (which was used in VB6, with JET databases, such as Access).
    I am not aware of a GetRecords method for use with ADO.NET

    Author Comment

    Visual Basic .NET: example of GetRecord method used in Northwinds database.

    Dim myRecord As OrdersRecord

    Dim whereStr As String = "EmployeeID='1'"

    myRecord = OrdersTable.GetRecord(whereStr)

    LVL 44

    Accepted Solution

    The OrdersTable class has a static GetRecord Method which returns, as a value, an object of type OrdersRecord.  That was built into the code from the class, and it is not a standard method found in just any class.  You would need to look at the code for the OrdersTable class, to see if you could modify it to meet your specific needs.  

    My guess, without seeing the actual source code, would be that in the present situation, the OrdersTable.GetRecord would return the most recent Order record for the indicated employee, based on the whereString.   Mind you, that is a guess.  

    I do not see how that is directly related to the Table that you have, but it may be possible to create a class, modelled on the OrderTable class, that might do the job.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now