Click here to Skip to main content
15,902,021 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
for login.... i entered the values as rollno in the registration table. how could i chek the input for login, entering rollno with the values present in the registration table?
Posted

C#
private void txtCourseName_Leave(object sender, EventArgs e)
        {
            SqlCon = DBCon.DBOpenConnection();
            Query = "Select distinct Name from tblDepartmentMaster";
            SqlCmd = new SqlCommand(Query, SqlCon);
            SqlDr = SqlCmd.ExecuteReader();
            while (SqlDr.Read())
            {
                txtName.Text = SqlDr.GetString(0).ToString();
            }
            MessageBox.Show("Already Exist the Name!", "Already Exist", MessageBoxButtons.OK, MessageBoxIcon.Information);
            txtCourseName.Clear();
            ActiveControl = txtCourseName;

            SqlDr.Close();

        }
 
Share this answer
 
C#
if (btnSave.Text == "Save")
        {
            SqlCommandBuilder cmdbSection;
            DataRow newrow;
            ds = new DataSet();
            ad = new SqlDataAdapter("select strTestName from PEHMstTest where strTestName='" + txttestname.Text + "'", SqlCon);
            ad.Fill(ds);
            if (ds.Tables[0].Rows.Count == 0)
            {
                DataSet ds1 = new DataSet();
                SqlDataAdapter ad1 = new SqlDataAdapter("select * from PEHMstTest", SqlCon);
                ad1.Fill(ds1);
                newrow = ds1.Tables[0].NewRow();
                newrow[0] = new_num();
                newrow[1] = txttestname.Text;
                newrow[2] = txtcharges.Text;

                ds1.Tables[0].Rows.Add(newrow);
                cmdbSection = new SqlCommandBuilder(ad1);
                ad1.Update(ds1);

                lblMsg.ForeColor = Color.Green;
                lblMsg.Text = "Records saved successfully";
            }
            else
            {
                lblMsg.ForeColor = Color.Red;
                lblMsg.Text = "Test Detail Already Exists, Give a different name.";
            }
           
        }


[edit]added pre tag[/edit]
 
Share this answer
 
v3
C#
DataSet ds = new DataSet();
            SqlDataAdapter ad = new SqlDataAdapter("select * from technicalregistration where strloginname='" + txtusername.Text + "' and strloginpwd='" + txtpassword.Text + "'", sqlcon);
            ad.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                Response.Redirect("Somepage.aspx");
            }
            else
                lblmessage.Text = "Invalid UserName and Password";

            txtusername.Text = "";
            txtpassword.Text = "";


You can go for this

[Edit]added pre tag[/Edit]
 
Share this answer
 
v3
write a simple query with a where clause for the roll no.
If the query returns a result, there is a row for that roll number in the table.

e.g.
select * from registration where rollno = ??
 
Share this answer
 
Comments
riodejenris 26-Dec-11 5:21am    
poi savu da....
AmitGajjar 26-Dec-11 7:42am    
please avoid non-english language...
if exists (select rollno from register table where condition)


it will return true if roll exists in table for that login

return false if not.
 
Share this answer
 

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