VB - MySQL Login Validation (DataReader)

.net , mysql Melaka, Malaysia
  • 12 years ago
    Hi there.
    I'm trying to create a Login Validation Control using ASP.NET and VB code and MySQL as database.
    Im currently facing all kinds of undefined errors with my code due to the SqlCommand,SqlConnection, etc as listed below. I've tried importing the namespaces in my code but it doesnt help. i got the info from some experts saying that some of the codes has been change for .net beta2 and is different from Beta1. but currently im using .net framework 2.0, but i still face the same problem.

    Btw, when i tried this on a different pc, it gives no error, but the validation is incorrect as some users are still able to login even with incorrect usernames and passwords while some registered users failed to login even with correct usernames and passwords. Am i missing any lines in my code? i cant figure out what the problem is. Please HELP~ PLEASE HELP HELP HELP~~~
    --------------------------------------------------------------------------------------------------
    Error    1    Syntax error.     
    Error    2    'SqlConnection' is a type and cannot be used as an expression.   
    Error    3    Method arguments must be enclosed in parentheses.   
    Error    4    Name 'myConnection' is not declared.   
    Error    5    Character is not valid.    
    Error    6    'SqlCommand' is a type and cannot be used as an expression.      
    Error    7    Method arguments must be enclosed in parentheses.   
    Error    8    Name 'myCommand' is not declared.    
    Error    9    Character is not valid.     
    Error    10    'SqlDataReader' is a type and cannot be used as an expression.      
    Error    11    Method arguments must be enclosed in parentheses. 
    Error    12    Name 'myDataReader' is not declared.     
    Error    13    Character is not valid.     
    Error    14    Name 'myConnection' is not declared.      
    Warning    15    'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'















    Error    16    Value of type 'System.Collections.Specialized.NameValueCollection' cannot be converted to 'String'.  
    Error    17    Identifier expected.   
    Error    18    Name 'myConnection' is not declared.   
    Error    19    Character is not valid.   
    Error    20    Syntax error.   
    Error    21    Name 'myCommand' is not declared.   
    Error    22    Name 'myConnection' is not declared.   
    Error    23    Character is not valid.   
    Error    24    Name 'myDataReader' is not declared.   
    Error    25    Name 'myCommand' is not declared.   
    Error    26    Character is not valid.   
    Error    27    'Boolean' is a type and cannot be used as an expression.   
    Error    28    '.' expected.   
    Error    29    'While' must end with a matching 'End While
    Error    30    Name 'myDataReader' is not declared.   
    Error    31    Syntax error.   
    Error    32    Name 'UserName' is not declared.   
    Error    33    Expression expected.   
    Error    34    Name 'myDataReader' is not declared.   
    Error    35    Name 'boolReturnValue' is not declared.   
    Error    36    Character is not valid.   
    Error    37    'If' must end with a matching 'End If'.   
    Error    38    Syntax error.   
    Error    39    'Return' statement in a Sub or a Set cannot return a value.   
    Error    40    Character is not valid.   
    Error    41    Syntax error.   
    Error    42    Name 'myDataReader' is not declared.   
    Error    43    Character is not valid.   
    Error    44    Name 'myConnection' is not declared.   
    Error    45    Character is not valid.  






























    ------------------------------------------------------------------------------------------------------


    <%@Page Language="VB" MasterPageFile="~/member/MemberMaster.master" Title="Untitled Page" %>

    <%@Import Namespace="System.Data" %>
    <%@Import Namespace="System.Data.SqlTypes" %>
    <%@Import Namespace="system.data.sqlClient" %>
    <%@Import Namespace="System.Web.Util" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder1" Runat="Server">
      
     <script runat="server">
        Public Sub Login1_OnClick(ByVal sender As Object, ByVal args As EventArgs)
            

     SqlConnection myConnection;
     SqlCommand myCommand;
     SqlDataReader myDataReader;
     
     myConnection = new SqlConnection(ConfigurationSettings.AppSettings["slimConnectionString"]);
     myConnection.Open();

     myCommand = new SqlCommand("SELECT Member_ID, Password FROM MEMBER", myConnection);
     myDataReader = myCommand.ExecuteReader();
     Boolean boolReturnValue;
     
     While (myDataReader.Read())
     {
      
        if ((UserIDBox == myDataReader["Member_ID"].ToString()) & (PasswordBox == myDataReader["Password"].ToString()))
                       
                                 boolReturnValue = true;
                        
        else { boolReturnValue = false; }
                         return boolReturnValue;
           }
      
     myDataReader.Close();
     myConnection.Close();
       
         End Sub
    </script>



















































Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth