THANKS!! (email = txtEmailAddress.Text And password =
txtPassword.Text) that got it to compile
ALSO I had a basic logic error in that I needed the login results
IfThen blocks to be inside the main IfThen of the Sub like this (which
is working perfectly now):
Private Sub btnLogin_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnLogin.Click
Dim ds As DataSet = New DataSet
ds.ReadXml(MapPath("members.xml"))
Dim email As String = ""
Dim password As String = ""
If ds.Tables(0).Rows.Count > 0 Then
email = ds.Tables(0).Rows(0)("EmailAddress").ToString()
password = ds.Tables(0).Rows(0)("Password").ToString()
If (email = txtEmailAddress.Text And password =
txtPassword.Text) Then
lblLoginFailure.Visible = True
lblLoginFailure.Text = "Welcome to Our Site."
Else
lblLoginFailure.Visible = True
lblLoginFailure.Text = "Email Address and/or Password
are incorrect. Please try again."
End If
End If
End Sub
On Mar 31, 2:03 pm, Joe Enos <[email protected]> wrote:
> == is not the equals operator in VB.NET.
>
> @Brock:
> I believe your code is not compiling because you're trying to compare
> a string to a textbox, not the contents of the textbox:
> (email = txtEmailAddress And password = txtPassword)
> should be
> (email = txtEmailAddress.Text And password = txtPassword.Text)
>
> FYI: There are better ways of accomplishing this rather than a dataset
> - XPath, serialization, etc.
> Also, I don't think it matters in this case, but it's good practice to
> keep case correct - when retrieving values from your dataset, the
> column names are capitalized differently from the XML element names.
>
> On Mar 31, 9:49 am, "Stephen Russell" <[email protected]> wrote:
>
>
>
> > == instead of =
>
> > .........................
> > Stephen Russell -
> > Senior Visual Studio Developer, DBA
>
> > Memphis, TN
> > 901.246-0159
>
> > > -----Original Message-----
> > > From: [email protected]
> > > [mailto:[email protected]] On Behalf Of Brock
> > > Sent: Tuesday, March 31, 2009 10:55 AM
> > > To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
> > > Services,.NET Remoting
> > > Subject: [DotNetDevelopment] querying XML for user login
>
> > > I'm trying to use an XML file like below for users to login to my
> > > website. I have some code started below, but I'm sure there's a better
> > > way. "(email = txtEmailAddress And password = txtPassword)" does not
> > > compile.
>
> > > <?xml version="1.0" standalone="yes"?>
> > > <members>
> > > <member>
> > > <firstName>Ralph</firstName>
> > > <lastName>Ward</lastName>
> > > <emailAddress>[email protected]</emailAddress>
> > > <password>1920</password>
> > > </member>
> > > </members>
>
> > > Private Sub btnLogin_Click(ByVal sender As System.Object, _
> > > ByVal e As System.EventArgs) Handles btnLogin.Click
>
> > > Dim ds As DataSet = New DataSet
> > > ds.ReadXml(MapPath("members.xml"))
> > > Dim email As String = ""
> > > Dim password As String = ""
>
> > > If ds.Tables(0).Rows.Count > 0 Then
> > > email = ds.Tables(0).Rows(0)("EmailAddress").ToString()
> > > password = ds.Tables(0).Rows(0)("Password").ToString()
> > > End If
>
> > > If (email = txtEmailAddress And password = txtPassword) Then
> > > lblLoginFailure.Visible = True
> > > lblLoginFailure.Text = "Welcome to Our Site."
> > > Else
> > > lblLoginFailure.Visible = True
> > > lblLoginFailure.Text = "Email Address and/or Password are
> > > incorrect. Please try again."
> > > End If
> > > End Sub
>
> > > No virus found in this incoming message.
> > > Checked by AVG -www.avg.com
> > > Version: 8.0.238 / Virus Database: 270.11.31/2029 - Release Date:
> > > 03/31/09 06:02:00- Hide quoted text -
>
> - Show quoted text -