www.webdeveloper.com
Results 1 to 3 of 3

Thread: .EOF not part of string.....error..

  1. #1
    Join Date
    Feb 2003
    Location
    Sault Ste Marie, On, Canada
    Posts
    168

    .EOF not part of string.....error..

    Hey guys this is my attempt at my first login script with .net and not sure why I'm getting this error: 'EOF' is not a member of 'String'. Any help?? Thx In advance!


    <%@ Page Language="vb" Debug="true" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.OleDb" %>
    <script runat="server">

    Sub Login(sender as Object, e as EventArgs)
    Dim myConn As OleDbConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & _
    "C:\Profiles\Databases\Members.mdb;" )

    Dim MySQL as string = "SELECT * FROM MEMBERS WHERE User_Id = @User_Id AND User_Password = @User_Password "
    MyConn.Open()

    Dim Cmd as New OleDbCommand(MySQL, MyConn)

    cmd.Parameters.Add(New OleDbParameter("@User_Id", User_Id.text))
    cmd.Parameters.Add(New OleDbParameter("@User_Password", User_Password.text))

    cmd.ExecuteNonQuery

    IF MySQL.EOF THEN
    NoUser.visible = True
    Else
    Response.Redirect("Account.aspx")
    End If

    MyConn.Close()
    End Sub


    </script>
    <html>
    <head>
    </head>
    <body>
    <form runat="server">

    <asp:TextBox id="User_Id" runat="server"></asp:TextBox>

    <asp:TextBox id="User_Password" runat="server"></asp:TextBox>

    <asp:Button id="cmdadd" onclick="Login" runat="Server" text="Login"></asp:Button>
    </form>


    <asp:Panel id="NoUser" runat="server" visible="False">Wrong Login Name or Password</asp:Panel>

    </body>
    </html>

  2. #2
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,222

  3. #3
    Join Date
    Nov 2004
    Location
    Utah
    Posts
    23
    Well the first thing is that a String value does not have a EOF property.

    You can do it a couple of ways. If all you are trying to do is to establish that something came back, then the fastest way to do this is probably like this:

    Code:
    Dim MySQL as string = "SELECT * FROM MEMBERS WHERE User_Id = @User_Id AND User_Password = @User_Password "
    MyConn.Open()
    
    Dim Cmd as New OleDbCommand(MySQL, MyConn)
    
    cmd.Parameters.Add(New OleDbParameter("@User_Id", User_Id.text))
    cmd.Parameters.Add(New OleDbParameter("@User_Password", User_Password.text))
    
    Dim myReader as OleDbDataReader
    
    myReader = cmd.ExecuteReader()
    
    If myReader.HasRows Then
      NoUser.visible = True
    Else
      Response.Redirect("Account.aspx")
    End If
    
    myReader.Close()
    MyConn.Close()
    If you need a different way you could do the If statement this way.

    Code:
    If myReader.Read() Then
      NoUser.visible = True
    Else
      Response.Redirect("Account.aspx")
    End If
    
    myReader.Close()
    MyConn.Close()
    * note that the HasRows is NOT available in 2002 (v1.0.3705) of the framework, only 1.1 (v1.1.4322)

    Ben Miller
    All responses are provided AS IS and do not necessarily reflect my employers views.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles