Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2004, 02:33 PM
Authorized User
 
Join Date: Oct 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML Data File

I am using XML to store a username and password information for users. The file looks something like this.

<?xml version="1.0" encoding="utf-8" ?>
<UserData xmlns="http://tempuri.org/cqUser.xsd">
    <User ID="1">
        <branchID>1</branchID>
        <FirstName>Matt</FirstName>
        <LastName>Fields</LastName>
        <LoginID>mattf</LoginID>
        <Password>1234</Password>
    </User>
    <User ID="2">
        <branchID>1</branchID>
        <FirstName>Jeff</FirstName>
        <LastName>Reynolds</LastName>
        <LoginID>jeffr</LoginID>
        <Password>55678</Password>
    </User>
</UserData>


From a windows form, I want to log into an application and authenticate using a valid user(one of the ones above). I have tried using the dataset and can not seem to evaluate a username and password for a table. I am new to XML so it may be simplier that I imagine.

Can anyone help. Thanks

 
Old January 28th, 2004, 01:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

How are you validating a user (form-based) or WindowsIdentity? What code are you using to get the information from the XML?
 
Old January 29th, 2004, 10:53 AM
Authorized User
 
Join Date: Oct 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using a windows form with a username and password box and login button. The code to get the data from the XML document and compare it to the username and password text box is what I am having issues with.

 
Old January 29th, 2004, 11:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try:
Code:
dim objDataSet as new DataSet
objDataSet.ReadXML(Server.MapPath("cgUser.XML"))
'This allows you to use the find method to retrieve the user ID
objDataSet.Tables(0).PrimaryKey = new DataColumn() {objDataSet.Tables(0).Columns("LoginID")}

'try to find the row of data with the user ID
dim objRow as DataRow = objDataSet.Tables(0).Rows.Find(strUserID)
'If the XML row with the user ID exists
if (not isNothing(objRow)) then
    'If password matches
    if ( objRow("Password") = strPassWord ) then
        'Validation successful
    end if
end if
Let me know if it works.

Thanks,

Brian Mains





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple input xml / get data from other xml file elayaraja.s XSLT 3 July 25th, 2008 06:59 AM
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
How to export the data to XML file format? mbshankar Pro VB 6 2 April 3rd, 2007 12:22 PM
Inserting data into a XML file zion99 ASP.NET 2.0 Basics 0 July 17th, 2006 09:57 AM
IS There A Way TO Download Data F Sql To Xml File alyeng2000 ASP.NET 1.0 and 1.1 Professional 4 April 28th, 2005 09:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.