loginForm xml file<PLEASE HELP>

need to varify the username and pasword against the information in xml

Page 1 of 1

12 Replies - 2715 Views - Last Post: 27 February 2009 - 08:26 PM Rate Topic: -----

#1 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

loginForm xml file<PLEASE HELP>

Posted 26 February 2009 - 11:15 AM

The last thing i have to do for my project i am working on is to verify my user name and password on my loginform with the user name and password in my customerc.xml file.

Ive been tryin to get this last part to work for a while and im gettin ne where so i hope one of you guys can help me out a little

-so i want to have the user type in his username in usernametextbox.text and password in passwordtextbox.text then have the program search throu the xml file for a match loginID (username) and password....if no match is found show error message,
and if a match is found then frmCustomermaintenance.show

heres an example of the xml file

<?xml version="1.0" encoding="utf-8" ?>
<Customers>
<Customer>
<FirstName>Jim</FirstName>
<LastName>Jones</LastName>
<Email>jonesj@rowan.edu</Email>
<Password>jjones</Password>
<IDnumber>1637</IDnumber>
<LoginID>1637</LoginID>
</Customer>
</Customers>


thanks to ne one who helps....i really appreciate it

-MILT-

This post has been edited by milton7888: 26 February 2009 - 11:59 AM


Is This A Good Question/Topic? 0
  • +

Replies To: loginForm xml file<PLEASE HELP>

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: loginForm xml file<PLEASE HELP>

Posted 26 February 2009 - 12:42 PM

What exactly are you looking for help with?

How I would do it is I would load the file using the System.Xml.Document class, then search for the right user with SelectSingleNode and XPath, get the password similarly (if I found the user), and compare the two. That's less than 10 lines of code without significant exception handling (in C# anyway).

But I don't know what you've learned in class/what you're expected to use to accomplish the XML reading.
Was This Post Helpful? 0
  • +
  • -

#3 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

Re: loginForm xml file<PLEASE HELP>

Posted 26 February 2009 - 01:12 PM

View PostJackOfAllTrades, on 26 Feb, 2009 - 11:42 AM, said:

What exactly are you looking for help with?

How I would do it is I would load the file using the System.Xml.Document class, then search for the right user with SelectSingleNode and XPath, get the password similarly (if I found the user), and compare the two. That's less than 10 lines of code without significant exception handling (in C# anyway).

But I don't know what you've learned in class/what you're expected to use to accomplish the XML reading.



the help i need is how you would get the select single node xpath to work ive read about if but cant get it to work correctly in my program....everytime ive tried i run my program click ok after typing in a login and password and it just explodes.....

can someone give me just an example code, if possible...

THANKS-

View PostJackOfAllTrades, on 26 Feb, 2009 - 11:42 AM, said:

What exactly are you looking for help with?

How I would do it is I would load the file using the System.Xml.Document class, then search for the right user with SelectSingleNode and XPath, get the password similarly (if I found the user), and compare the two. That's less than 10 lines of code without significant exception handling (in C# anyway).

But I don't know what you've learned in class/what you're expected to use to accomplish the XML reading.



the help i need is how you would get the select single node xpath to work ive read about if but cant get it to work correctly in my program....everytime ive tried i run my program click ok after typing in a login and password and it just explodes.....

can someone give me just an example code, if possible...

THANKS-
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: loginForm xml file<PLEASE HELP>

Posted 26 February 2009 - 01:30 PM

Selects the Customer node with the given username:
doc.SelectSingleNode("/Customers/Customer[LoginID='" + userName + "']");

Was This Post Helpful? 0
  • +
  • -

#5 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

Re: loginForm xml file<PLEASE HELP>

Posted 26 February 2009 - 08:20 PM

("/Customers/Customer[LoginID='" + userName + "']")

what does the login + username and all that do?.......i think im geting very clsoe to having this work..
Was This Post Helpful? 0
  • +
  • -

#6 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

Re: loginForm xml file<PLEASE HELP>

Posted 26 February 2009 - 08:36 PM

Dim username As String
Dim password As String

password = PasswordTextBox.Text
username = UsernameTextBox.Text


Dim xmldoc As New System.Xml.XmlDocument()

xmldoc.Load("customers.xml")



xmldoc.SelectSingleNode("/Customers/Customer[LoginID]")


'does this look right so far, if so how do i know compare that to whats in 'the textbox if tried evrythign i can think of and it pretty much all just 'makes errors show up...
'thanks!
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: loginForm xml file<PLEASE HELP>

Posted 27 February 2009 - 09:17 AM

I don't really know VB.NET, so this is a bit of a guess.
' Get customer node for given username
XmlNode customerNode = xmldoc.SelectSingleNode("/Customers/Customer[LoginID = ''" + username + "'']")
if (customerNode is Not Nothing) then
    Dim savedPassword as string
    savedPassword = customerNode.SelectSingleNode("Password").InnerText
    'compare savedPassword and password
endif

Was This Post Helpful? 0
  • +
  • -

#8 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

Re: loginForm xml file<PLEASE HELP>

Posted 27 February 2009 - 10:09 AM

yeah this code is comin up with alot of errors can someone who knows vb.net take a look and clean it up for me thanks
Was This Post Helpful? 0
  • +
  • -

#9 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: loginForm xml file<PLEASE HELP>

Posted 27 February 2009 - 12:26 PM

Don't *you* know VB.NET? Shouldn't you be able to figure out what's wrong and fix it?
Was This Post Helpful? 0
  • +
  • -

#10 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

Re: loginForm xml file<PLEASE HELP>

Posted 27 February 2009 - 12:44 PM

	 Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
		customercheck()
 

	  
	End Sub

	Sub customercheck()

		Dim customers As New List(Of Customer)
		Dim xmlIn As New XmlTextReader(Path)
		xmlIn.WhitespaceHandling = WhitespaceHandling.None

		Do While xmlIn.Name <> "Customer"
			xmlIn.Read()

		Loop

		Do While xmlIn.Name = "Customer"
			Dim customer As New Customer
			xmlIn.ReadStartElement("Customer")
			customer.FirstName = xmlIn.ReadElementString("FirstName")
			customer.LastName = xmlIn.ReadElementString("LastName")
			customer.Email = xmlIn.ReadElementString("Email")
			customer.Password = xmlIn.ReadElementString("Password")
			customer.IDnumber = xmlIn.ReadElementString("IDnumber")
			customer.LoginID = xmlIn.ReadElementString("LoginID")
			xmlIn.ReadEndElement()


			If customer.LoginID = UsernameTextBox.Text Then


				If customer.Password = PasswordTextBox.Text Then
					frmCustomerMaintenance.Show()


				End If
			End If
		
		Loop
	End Sub



i want to be able to have if no match was found then....messagebox.show("lashkflhfhlsldkhf")
can someone help me with that, cause i dont want it to show for each time it goes throu the loop
thanks
Was This Post Helpful? 0
  • +
  • -

#11 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

Re: loginForm xml file<PLEASE HELP>

Posted 27 February 2009 - 06:24 PM

View PostJackOfAllTrades, on 27 Feb, 2009 - 11:26 AM, said:

Don't *you* know VB.NET? Shouldn't you be able to figure out what's wrong and fix it?


no i dont anything about usin xml in vb.net
Was This Post Helpful? 0
  • +
  • -

#12 nritzau  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 66
  • Joined: 31-January 09

Re: loginForm xml file<PLEASE HELP>

Posted 27 February 2009 - 06:29 PM

View Postmilton7888, on 27 Feb, 2009 - 05:24 PM, said:

View PostJackOfAllTrades, on 27 Feb, 2009 - 11:26 AM, said:

Don't *you* know VB.NET? Shouldn't you be able to figure out what's wrong and fix it?


no i dont anything about usin xml in vb.net


This may help
http://www.youtube.c...re=channel_page
Was This Post Helpful? 0
  • +
  • -

#13 milton7888  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-September 08

Re: loginForm xml file<PLEASE HELP>

Posted 27 February 2009 - 08:26 PM

thanks for trying guys, i got it to work
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1