Tuesday, January 25, 2011

For general discussion and problems

Please write your problems/questions about semester projects below in comments section.

33 comments:

Waqas Kashi said...

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

Waqas Kashi said...

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

Sheikh said...

Please send me your database table information where you are going to store user credentials.

Waqas Kashi said...

table name is User it has two columns Name,password.

Waqas Kashi said...
This comment has been removed by a blog administrator.
Sheikh said...
This comment has been removed by the author.
Sheikh said...

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;
}
}
}

Sheikh said...

Waqas,

Did that help or not?

Thanks

Waqas Kashi said...

sir kindly tell me this query for sql server database where username and password authanticate through textbox.

Sheikh said...

Did you try the code I wrote in my previous reply?

Waqas Kashi said...

sir i have tried this code but this gives error and my database is also in sql server.

Sheikh said...

Give me the error details.

Sheikh said...

Tell me one thing is your database connection user and the user you are authenticating same?

Sheikh said...

Send me your project I'll try to help you credential verification.

Sheikh said...

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.

Waqas Kashi said...

Sir thank You very much .I have tried this.
It is working now.

Amara Rehman said...
This comment has been removed by the author.
Amara Rehman said...
This comment has been removed by the author.
Sheikh said...

I've never worked on JSF but I can look for someone who can help with it. If you want?

Waqas Kashi said...

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.

Sheikh said...

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.

Amara Rehman said...
This comment has been removed by the author.
Waqas Kashi said...

Thank you sir .

Sheikh said...

@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.

Amara Rehman said...

Thankyou sir.
i have put functionality of product(add,update,delete,search,items check-in checkout n monthly reports of inventory shortage.)

Amara Rehman said...

Thankyou sir.

Waqas Kashi said...

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.

sadia batool said...

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

Amara Rehman said...

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

Sheikh said...

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?

sidra shaukat said...

Aslam-0-Alikum...
sir can you send all those lab practices that we done in the class...? it can help me to understand better....

sidra shaukat said...

Aslam-0-Alikum...
sir can you send all those lab practices that we done in the class...? it can help me to understand better....

Sheikh said...

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