Sorry.
We do not do your work for you. Please post some code, and we'll help troubleshoot it.
Incidentally, if you search our forums, you'll probably find some examples of an ASP.NET login page.
alc6379
Cookie... That's it
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
There was a well written example of a login screen posted on these boards very recently.
As alc6379 mentioned, the policy at Daniweb is to show that you have made an effort before posting your problems. We will gladly offer you guidance and fixes to get your code working, but you need to do the ground work first. Especially with a topic as common as this, there are a hudnred and one tutorials, just put "C# login form" into google and start reading :)
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
Please my problem has brought me to the good community of yours. i 've been try to write asp.net /c# code to validate user input 'pin' on the textbox in the sql database. if the pin is exist in the dbs then i delet it from the table it exist and insert it another table. only validation has been giving me sleepless night.
pls even though am new, ijust need the help of brothers. pls somebody help me out. here is the code i have been trying to work on my submit button:
DataTable pinTable = new DataTable();
try
{
SqlConnection connection = null;
string conn = ConfigurationManager.ConnectionStrings["SchooldataConnectionString1"].ConnectionString;
string found = "SELECT * FROM Allpindbs";
connection = new SqlConnection(conn);
connection.Open();
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = new SqlCommand(found, connection);
dAdapter.Fill(pinTable);
connection.Close();
}
catch (Exception ERR)
{
throw ERR;
}
foreach (DataRow oRow in pinTable.Rows)
{
PinCode.CompareTo(oRow["Pin"].ToString());
}
if (PinCode.CompareTo("Pin".ToString()) == 0)
{
MessageBox.Show("pin must be deleted");
}
else
{
MessageBox.Show("Invalid pin");
}
}
private void clearControls()
{
this.txtFullName.Text = " ";
this.txtRegNumber.Text = " ";
this.txtPinCode.Text = " ";
this.ddlGender.Text = " ";
this.txtLbl.Text = " ";
this.txtpassword.Text = " ";
}
}
DataTable pinTable = new DataTable();
try
{
SqlConnection connection = null;
string conn = ConfigurationManager.ConnectionStrings["SchooldataConnectionString1"].ConnectionString;
string found = "SELECT * FROM Allpindbs";
connection = new SqlConnection(conn);
connection.Open();
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = new SqlCommand(found, connection);
dAdapter.Fill(pinTable);
connection.Close();
}
catch (Exception ERR)
{
throw ERR;
}
foreach (DataRow oRow in pinTable.Rows)
{
PinCode.CompareTo(oRow["Pin"].ToString());
}
if (PinCode.CompareTo("Pin".ToString()) == 0)
{
MessageBox.Show("pin must be deleted");
}
else
{
MessageBox.Show("Invalid pin");
}
}
private void clearControls()
{
this.txtFullName.Text = " ";
this.txtRegNumber.Text = " ";
this.txtPinCode.Text = " ";
this.ddlGender.Text = " ";
this.txtLbl.Text = " ";
this.txtpassword.Text = " ";
}
}
denmarkstan
Junior Poster in Training
59 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Firstly, you are looping through each row but not storing the result of your test anywhere. I would suggest something like:
bool found = false;
foreach(DataRow dr in Table.Rows)
{
if(dr["column"].ToString() == "somestring")
{
found = true; //store result
break; //exit foreach loop as you no longer need to search remaining items
}
if(found)
{
//perform action based on result
}
}
Secondly, you are using the wrong string method. IF you take a look at the msdn reference , you'll find:
Caution!
The CompareTo method was designed primarily for use in sorting or alphabetizing operations. It should not be used when the primary purpose of the method call is to determine whether two strings are equivalent. To determine whether two strings are equivalent, call the Equals method.
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246