Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
See more:
C#
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class loginpage : System.Web.UI.Page
{
    exploringapplication ea = new exploringapplication();
    DataSet data = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

       
        if (TextBox1.Text == "")
        {
            MsgBox.Show("Enter the UserName");
        }
        if (TextBox1.Text != "")
        {
            if (TextBox2.Text == "")
            {
                MsgBox.Show("Enter the Password");
            }
        }

        if (TextBox1.Text != "" && TextBox2.Text != "")
        {
                data = ea.selectuserdata();
                if (TextBox1.Text == data.Tables[0].Rows[0]["email"].ToString() && TextBox2.Text == data.Tables[0].Rows[0]["dob"].ToString())
                {
                    Response.Redirect("select.aspx");
                }
                else
                    MsgBox.Show("Enter the correct data");
            
        }
        
    }
}
Posted
v2

Your DataSet is referenced with new keyword and it doesn't have any data within it. So if you put a breakpoint over there, after debugging it you might null value.
And one thing as well, I don't know what ea.selectuserdata() is returning, I mean it must a database operation but for which user it is selecting data ?

So modify you code this way, (you can alter it later, as per the nature of the application)
C#
public DataTable SelectUserData(string email, string password)
{
string str = "select * from user where email = '" + email + "', password = '" + password + "'" ;
SqlDataAdapter da = new SqlDataAdapter(str, connectionObj);
DataTable dt = new DataTable();
da.Fill(dt);

return dt;
}

protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == "")
        {
            MsgBox.Show("Enter the UserName");
        }
        if (TextBox1.Text != "")
        {
            if (TextBox2.Text == "")
            {
                MsgBox.Show("Enter the Password");
            }
        }
 
        if (TextBox1.Text != "" && TextBox2.Text != "")
        {
               DataTable dt = ea.SelectUserData(TextBox1.Text, TextBox2.Text);

                if(dt.Rows.Count > 0)
                Response.Redirect("SomePage.aspx");
                else
                Response.Redirect("SomeOtherPage.aspx");

        }
        
    }

-KR
 
Share this answer
 
Comments
Krunal Rohit 22-Feb-14 23:59pm    
I'm not using TeamViewer.
And what error are you getting anyway ?

-KR
phani dhar 23-Feb-14 0:05am    
ERROR " a connection was succesfully established with the server, but then an error occured during the the login process (provider :shared memory provider , error 0-No process is on the other end of the pipe
Krunal Rohit 23-Feb-14 0:07am    
go to SQL Server Configuration Manager (SSCM) and:

ensure Shared Memory protocol is enabled
ensure Named Pipes protocol is enabled
ensure TCP/IP is enabled, and s ahead of the Named Pipes in the settings

and you can look here as well :
http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
phani dhar 23-Feb-14 0:12am    
please can u come to team viewer!!...if u have Mail ID its easy to get into team viewer.

http://www.filehippo.com/download_teamviewer/
Krunal Rohit 23-Feb-14 0:13am    
I'm busy with other stuff as well.
Just go through that link :)
-KR
You need to provide more information. What do you expect to happen? What is happening? What errors are you getting?

But first item I will tell you is that MsgBox does not work on web forms. That is for windows apps.
 
Share this answer
 
Comments
phani dhar 22-Feb-14 21:41pm    
Actually i am trying to make a login WEB page // but it once worked perfectly...my username is EMAIL and MY PASSWORD is DATE OF BIRTH ...can u solve it now please!
phani dhar 22-Feb-14 21:46pm    
I am not getting any error !! and mean while the concept of this code is :

1) register

2) login with username(email) and password (dob) which are storing perfectly in database

3)redirect to SELECT.ASPX page

but now my problem is,, i am able to registered succesfully and unable to login with that CODE and mean while no error were raised and showing ENTER CORRECT DATA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900