1
Answer

MS Access DB Help

Photo of adam

adam

14y
7k
1
I have a program with a MS Access DB that holds the login details for users.

I really cant work out how to connect to the database and check to see if the login username and then password that are enetered are the same as those in the databse..

Can anyone guide me in the right direction?

Thanks in advance

Answers (1)

1
Photo of Hirendra Sisodiya
NA 8.8k 3m 14y
hello adam


try this

OleDbConnection oCon = new OleDbConnection("Put your Connection string");
            oCon.Open();
            object obj;

            string str = "Select count(*) from tablename where Login='" + UserId + "' ams password ='" + password + "' ";
            OleDbCommand cmd = new OleDbCommand(str, oCon);
            obj = cmd.ExecuteScalar();
            if ((int)obj!= 0)
            {
                //Login successfull
            }
            else
            {
                // Unsuccessfull
            }

thanks



please mark as answer if it helps

Accepted