简体   繁体   English

在ASP.NET中联接表

[英]Joining Tables in ASP.NET

Ambiguous Error.. It highlights this line: 模棱两可的错误..它突出显示了这一行:

bojDA.Fill(objDS, "ShopCart");

and right above that is my select statement which looks like: 右上方是我的select语句,如下所示:

any advice on this issue now would be helpful, thank you 关于此问题的任何建议现在都会有所帮助,谢谢

Thank you 谢谢

I think the new error has something to do with: 我认为新错误与以下内容有关:

SELECT productid,productname,productsku,quantity,productprice,productprice * quantity AS TotalPrice,ShoppingCartRecID,UOM,PackingSlip,LogoDesignNumber,CustomText,NameText,ExtraCharge,custitem,t1.CatalogType,CatalogID,RelatedChargeID,UPSFlag FROM ShoppingCart t1 INNER JOIN ItemCatalogProfile t2 on t1.CatalogType = t2.Integration

when i try entering this into SQL Server, it just pulls back empty columns 当我尝试将其输入SQL Server时,它只会拉回空列

Just join the tables in the select query that's used to bind the GridView (or other databound control), like this: 只需将表联接到用于绑定GridView(或其他数据绑定控件)的select查询中,如下所示:

SELECT Table1.Column1,
       Table2.Column2
FROM   Table1
       INNER JOIN Table2
           ON Table1.SomeColumn = Table2.SomeColumn

There are two ways to work with data from a persistant store. 有两种方法来处理持久性存储中的数据。 One is to grab raw data and attempt to shape it on the UI layer. 一种是获取原始数据,然后尝试在UI层上对其进行成形。 The other is to shape the data when you retrieve it. 另一种是在检索数据时对数据进行整形。 Okay, technically, you can shape the data at any layer. 好的,从技术上讲,您可以在任何层上对数据进行整形。

Your issue is largely due to having one data definition throughout your application. 您的问题很大程度上是由于在整个应用程序中只有一个数据定义。 You have the same data definition in the database, the business logic and the UI. 您在数据库,业务逻辑和UI中具有相同的数据定义。 For some of the layers, separating out the data into two "sources" (or similar), where the data has different names, depending on context. 对于某些层,将数据分成两个“源”(或类似名称),其中数据根据上下文具有不同的名称。

The direction I would take to solve the problem is create a "view model" that has the bits named correctly for the purpose of this particular page. 解决该问题的方向是创建一个“视图模型”,该模型具有正确命名的位,以用于此特定页面。 You need not change the data structure throughout all layers to do this. 您无需更改所有层的数据结构即可执行此操作。 Just shape the data for the UI before you bind it. 绑定UI之前,只需对UI的数据进行整形即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM