c# verifying Login Info from 2 different tables in Database

Posted on 2011-04-22
Last Modified: 2012-05-11
i have 2 tables   in access

1) Customer  - lastname,firstname.
2)Login - UserID , Pin .

im trying to verify the username and pin from login table , then return the lastname and first name from the customer table.  

i keep getting this error " No value given for one or more required parameters."

public  static string LognCus(string a, string b)
          string UsNamess = a;
          string PassWd = b;

          OleDbCommand cmd = DbUtils.GetCommand();
          cmd.CommandType = CommandType.Text;
          cmd.CommandText = "Select Login.UserID,Login.Pin,Cusomter.LastName,Customer.FirstName FROM [Login] INNER JOIN [Customer] ON Login.[ID]=Customer.[ID]  WHERE Login.UserID='" + UsNamess + "' AND Login.Pin='" +(Convert.ToInt32( PassWd)) + "'";

          OleDbDataReader rdr = null;
          rdr = cmd.ExecuteReader();

          string usname = string.Empty;

          if (rdr.Read() == true)
              usname = rdr["Customer.FirstName"].ToString() + " " + rdr["Customer.LastName"].ToString();


          return usname;

Open in new window

Question by:Ajs135
    LVL 8

    Accepted Solution

    You have a typo.  In your select statement, change Cusomter.LastName to Customer.LastName
    LVL 21

    Assisted Solution

    by:Alpesh Patel
    Missing parameter to pass in Query.

    After assignment Please check value of  cmd.CommandText. It will give you better answer.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now