I am doing a project using the AdventureWorks database and I am trying to access the database so that users can change their credentials. Users for the website are configured using the ASP.NET configuration manager, so I'm not sure how to do this. I have a GetCustomer Select method configured to select (at the moment) only the first and last client names in the Person.Contact table.
[DataObject(true)] public static class CustomerDB { [DataObjectMethod(DataObjectMethodType.Select)] public static List<Customer> GetCustomer() { List<Customer> CustomerList = new List<Customer>(); SqlConnection con = new SqlConnection(GetConnectionString()); string sel = "SELECT Person.Contact.FirstName, Person.Contact.LastName " + "FROM Person.Contact " + "JOIN Sales.Individual ON Person.Contact.ContactID = Sales.Individual.ContactID " + "JOIN Sales.Customer ON Sales.Individual.CustomerID = Sales.Customer.CustomerID " + "WHERE Sales.Customer.CustomerType = Sales.Individual " + "ORDER BY Person.Contact.LastName, Person.Contact.FirstName"; SqlCommand cmd = new SqlCommand(sel, con); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Customer customer; while (rdr.Read()) { customer = new Customer(); customer.FirstName = rdr["FirstName"].ToString(); customer.LastName = rdr["FirstName"].ToString(); CustomerList.Add(customer); } rdr.Close(); return CustomerList; } private static string GetConnectionString() { return ConfigurationManager.ConnectionStrings ["AdventureWorksString"].ConnectionString; }
But I get an error: Msgstr "Invalid object name" Person.Contact "." which makes me think this is a problem. The query I'm using is based on one example script on the Msdn website. If someone could point me in the right direction, taking into account which tables to use to obtain information about the client, so that the user can change his address and password, I would be very grateful!
source share