希望这很简单。我有一个存储过程,检查数据库中的各种表,以查看项目是否有库存。我尝试重复使用相同的过程并仅提取其中的一部分来检查现场其他地方的库存水平,但该过程的输出仅转换为字符串。
我尝试将此字符串输出到文本框以查看其有用程度,我最终将此未格式化的HTML代码作为字符串结果:
<div class="product-column-right-location"> </div>
<div class="product-column-right-stock">
<strong>Stock</strong></div>
<div class="product-column-right-committed">
<strong>Committed</strong></div>
<div class="product-column-right-on-order">
<strong>On Order</strong></div>
<div class="product-column-right-available"><strong>Available</strong> </div><div class="product-column-right-location">
<a href="/contact-us.aspx" alt="Global PC Tower Junction contact information" Title="Global PC Tower Junction contact information">Tower Junction - Riccarton</a></div>
<div class="product-column-right-stock">0</div><div class="product-column-right-committed">0</div><div class="product-column-right-on-order">0</div><div class="product-column-right-available">0</div><div class="product-column-right-location"><a href="/contact-us.aspx" alt="Global PC Homebase contact information" Title="Global PC Homebase contact information" >Homebase - Shirley</a></div><div class="product-column-right-stock">0</div><div class="product-column-right-committed">0</div><div class="product-column-right-on-order">0</div><div class="product-column-right-available">0</div><div class="product-column-right-location">In-Transit</div><div class="product-column-right-stock">0</div><div class="product-column-right-committed">0</div><div class="product-column-right-on-order">0</div>
<div class="product-column-right-available">0</div>
<div class="product-column-right-location">Warehouse</div><div class="product-column-right-stock">0</div><div class="product-column-right-committed">0</div><div class="product-column-right-on-order">0</div><div class="product-column-right-available">0</div>
我感兴趣的部分是这一行
<div class="product-column-right-available">0</div>
是一种简单的方法来破解和削减并将那个巨大的字符串切割成我感兴趣的部分吗?或者我可以轻松地将返回的ASP代码转换为可用的数据表吗?
我已经尝试过对SQL服务器的不同请求,看看我是否可以获得一列而不是所有内容,但它在那里很乱,我没有足够的访问权限开始清理它。
答案 0 :(得分:0)
问题解决了,在找到实际在服务器调用后面的两个程序后,我设法从中获得了正确的答案。对服务器的主要调用实际上只是运行这两个SQL查询的简单方法。
SqlHelper.ExecuteScalar(System.Configuration.ConfigurationManager.AppSettings("dbConn").ToString, "xw_GetStockLevelInOut", "productID", "Location")
SqlHelper.ExecuteScalar(System.Configuration.ConfigurationManager.AppSettings("dbConn").ToString, "xw_GetWarehouseStockLevelInOut", "productID", "Location")
它返回三个字符串,我只是使用基本的If语句进行比较。使用字符串作为基本库存计数的结果似乎很奇怪,但也许只是我?
E.G:
Dim one As String = SqlHelper.ExecuteScalar(System.Configuration.ConfigurationManager.AppSettings("dbConn").ToString, "xw_GetStockLevelInOut", "sr08509", 4)
Dim two As String = SqlHelper.ExecuteScalar(System.Configuration.ConfigurationManager.AppSettings("dbConn").ToString, "xw_GetWarehouseStockLevelInOut", "sr08509", 11)
Dim three As String = SqlHelper.ExecuteScalar(System.Configuration.ConfigurationManager.AppSettings("dbConn").ToString, "xw_GetStockLevelInOut", "sr08509", 12)
If one = "Out of Stock." And two = "Out of Stock." And three = "Out of Stock." Then
oos = True
imgStock.ImageUrl = "images/oos-call-for-availability.png"
imgStock.AlternateText = "This item is out of stock"
Else
oos = False
imgStock.ImageUrl = "images/in-stock.png"
imgStock.AlternateText = "This item is in stock"
End If
还有一些关于确切地在页面上运行此代码的位置的调整,以使其能够独立地为每个产品工作,但是它给了我正在寻找的信息。