我正在使用AdventureWorks数据库进行项目,我正在尝试访问数据库,以便用户可以更改其帐户信息.该网站的用户是使用ASP.NET配置管理器设置的,所以我不确定如何去做.我有一个GETCUSTOMER选择方法设置为取(此时)刚刚在Person.Contact表的客户的名字和姓氏.
[DataObject(true)] public static class CustomerDB { [DataObjectMethod(DataObjectMethodType.Select)] public static ListGetCustomer() { List CustomerList = new List (); 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; }
但是我收到的错误是:"无效的对象名称'Person.Contact'." 这让我觉得这是问题的查询.我正在使用的查询基于Msdn网站上的一个示例场景.如果有人能够指出我使用哪些表来获取客户信息以便用户能够更改他们的地址和密码,我将非常感激!