sir i want to create a login page in window form and want to authenticate the username password from database . user will provide usename and password in textbox. kindly tell me the code. waqas azeem
sir i want create a login form in window base application. i want to authenticate it fron database user will provide username and password in textbox.kindly tell me teh code
// Open connection con.Open(); // Execute object obj = cmd.ExecuteScalar(); if (obj != null) { nCount = (int)obj; if (nCount > 0) return true; // user id and password authenticated else return false; // user id / password authentication failed } else { return false; // Invalid user id / password, authentication failed or user does not exist } } catch (OdbcException odbcex) { throw new Exception("Unable to connect to the specified database. Please check your User ID, Password, and Data Source Name.", odbcex); } finally { cmd.Dispose(); cmd = null; // Close connection if (con.State == ConnectionState.Open) con.Close(); con.Dispose(); con = null; } } }
I've changed your project now it will work. You need to chnage the connection string according to your system . Also need to add some records in that table for testing.
Also added logout menu item in form 2.
See your email for changed files. Hope this will help.
Aslam-0-Alikam Sir i am facing a problem during insertion and updation in database tables. I want to insert data into to tables at once one table is Customer and other is Routes.In route table there are two columns RouteId and RouteName and in Customer table Columns are Name,Address,City,RouteID. I want to insert data into Customer and also want to add its routename.How can i insert data in both tables at a time.My project is Window Based and in C#.Database is in SQL Sever 2005.Kindly help me.
Which of these is the parent table? Customer or Route?
Looks like Route is your parent table, so to add records in both tables you need to first insert record in route, get the route id and then insert in customer table.
Inventory Management can include Assets/items check-in checkout through bar code reading. Reporting on stock cosumed and available etc. Also you can have asset tracking fuctionality.
Here you need to decide which of these fuctionalities applies to your project and doable within time lines.
Aslam-o-alikam sir i want to pass textbox as a parameter into a datagrid and i also want to save all the data of datagrid into databse in c# using SQL Server2005. kindly tell me the code for this.
Aslam o Alaikum sir i am sending a code that will help us in Optical Character Recognition i have take this code from internet but i am unable to fit it in the whole program. kindly help me that where it shoud be... Sadia Batool
Asslam o Alaikum sir 10 days before i have join a software house , working with php,jscript,css,mysql etc. but my performance is like zero , i want to work but i cant understand how to do the things , if u know about it then kindly help me or refer anyone who can guaide me. Thankyou. Amara Rehman
I will see if can be of any help? Try learning PHP and other technologies your org working in. Infcat can you tell me what exactly is the problem you are facing?
33 comments:
sir i want to create a login page in window form and want to authenticate the username password from database . user will provide usename and password in textbox. kindly tell me the code.
waqas azeem
sir i want create a login form in window base application. i want to authenticate it fron database user will provide username and password in textbox.kindly tell me teh code
Please send me your database table information where you are going to store user credentials.
table name is User it has two columns Name,password.
See the following code snippet, here I am assuming that you will be using DSN to connect to your database.
public class SecuritySettings
{
public static int AuthenticateUser(string dsnName, string userid, string password)
{
OdbcConnection con = new OdbcConnection("DSN=" + dsnName + ";" +
"UID=" + userid + ";" +
"PWD=" + password + ";"
);
int nCount = 0;
string query = string.Format("select COUNT('X') from User where Name={0} and Password={1}",userid,password);
OdbcCommand cmd = null;
// Execute Query
try
{
//Prepare Command
cmd = con.CreateCommand();
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
// Open connection
con.Open();
// Execute
object obj = cmd.ExecuteScalar();
if (obj != null)
{
nCount = (int)obj;
if (nCount > 0)
return true; // user id and password authenticated
else
return false; // user id / password authentication failed
}
else
{
return false; // Invalid user id / password, authentication failed or user does not exist
}
}
catch (OdbcException odbcex)
{
throw new Exception("Unable to connect to the specified database. Please check your User ID, Password, and Data Source Name.", odbcex);
}
finally
{
cmd.Dispose();
cmd = null;
// Close connection
if (con.State == ConnectionState.Open)
con.Close();
con.Dispose();
con = null;
}
}
}
Waqas,
Did that help or not?
Thanks
sir kindly tell me this query for sql server database where username and password authanticate through textbox.
Did you try the code I wrote in my previous reply?
sir i have tried this code but this gives error and my database is also in sql server.
Give me the error details.
Tell me one thing is your database connection user and the user you are authenticating same?
Send me your project I'll try to help you credential verification.
I've changed your project now it will work. You need to chnage the connection string according to your system
.
Also need to add some records in that table for testing.
Also added logout menu item in form 2.
See your email for changed files.
Hope this will help.
Sir thank You very much .I have tried this.
It is working now.
I've never worked on JSF but I can look for someone who can help with it. If you want?
Aslam-0-Alikam
Sir i am facing a problem during insertion and updation in database tables. I want to insert data into to tables at once one table is Customer and other is Routes.In route table there are two columns RouteId and RouteName and in Customer table Columns are Name,Address,City,RouteID. I want to insert data into Customer and also want to add its routename.How can i insert data in both tables at a time.My project is Window Based and in C#.Database is in SQL Sever 2005.Kindly help me.
Which of these is the parent table? Customer or Route?
Looks like Route is your parent table, so to add records in both tables you need to first insert record in route, get the route id and then insert in customer table.
if you do it reverse you will get errors.
Thank you sir .
@Ammara:
Inventory Management can include Assets/items check-in checkout through bar code reading.
Reporting on stock cosumed and available etc. Also you can have asset tracking fuctionality.
Here you need to decide which of these fuctionalities applies to your project and doable within time lines.
Thankyou sir.
i have put functionality of product(add,update,delete,search,items check-in checkout n monthly reports of inventory shortage.)
Thankyou sir.
Aslam-o-alikam
sir i want to pass textbox as a parameter into a datagrid and i also want to save all the data of datagrid into databse in c# using SQL Server2005. kindly tell me the code for this.
Aslam o Alaikum
sir i am sending a code that will help us in Optical Character Recognition i have take this code from internet but i am unable to fit it in the whole program.
kindly help me that where it shoud be...
Sadia Batool
Asslam o Alaikum sir
10 days before i have join a software house , working with php,jscript,css,mysql etc. but my performance is like zero , i want to work but i cant understand how to do the things , if u know about it then kindly help me or refer anyone who can guaide me.
Thankyou.
Amara Rehman
Amara,
I will see if can be of any help?
Try learning PHP and other technologies your org working in.
Infcat can you tell me what exactly is the problem you are facing?
Aslam-0-Alikum...
sir can you send all those lab practices that we done in the class...? it can help me to understand better....
Aslam-0-Alikum...
sir can you send all those lab practices that we done in the class...? it can help me to understand better....
I did not have those exercises' code with me. May be someone has copied it from the lab.
You can check it with your fellows
Post a Comment