我有一个Web应用程序,我想从外部网页获取h1标签和第一个图像以及前几行文本.我之前从未这样做过,认为使用jquery做得最好,但我不确定.你能否指出我正确的方向或在.net和jquery中给出一个编码示例?谢谢.
当我在邮箱中输入一个网址作为一个新帖子时,我想像Facebook一样拉出图片和几行.
我需要许多(16)个不同的查询来同时获取行数.我正在运行16个不同的连接,但我认为我可以合并到只有1个存储过程.
我遇到了麻烦,因为它为此行的datareader(系统超出范围检测)提供了错误:
Count2 = Convert.ToInt32(objDRL("Row_Count2").ToString).
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
Dim strConn As String = "Data Source=myDataSource"
Dim Conn As New SqlConnection(strConn)
Dim Cmd As New SqlCommand("adminStats", Conn)
Cmd.CommandType = CommandType.StoredProcedure
Dim objDRL As SqlDataReader
Cmd.Parameters.Add(New SqlParameter("@campDate", "June 2014"))
Conn.Open()
objDRL = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
If objDRL.HasRows Then
While objDRL.Read()
Count1 = Convert.ToInt32(objDRL("Row_Count1"))
Count2 = Convert.ToInt32(objDRL("Row_Count2"))
Count3 = Convert.ToInt32(objDRL("Row_Count3"))
Count4 = Convert.ToInt32(objDRL("Row_Count4"))
Count5 = Convert.ToInt32(objDRL("Row_Count5"))
Count6 = Convert.ToInt32(objDRL("Row_Count6"))
Count7 = Convert.ToInt32(objDRL("Row_Count7"))
Count8 = Convert.ToInt32(objDRL("Row_Count8"))
Count9 = Convert.ToInt32(objDRL("Row_Count9"))
Count10 = Convert.ToInt32(objDRL("Row_Count10"))
Count11 = Convert.ToInt32(objDRL("Row_Count11"))
Count12 = Convert.ToInt32(objDRL("Row_Count12")) …Run Code Online (Sandbox Code Playgroud) 我有以下代码,它可以在我尝试抓取信息的某些网站上运行,但它不能在我尝试过的特定网站上运行,并且我收到错误"底层连接已关闭:连接意外关闭. " 为什么这会在某些网站而不是其他网站上运行?例如,如果在siteA上使用,我将获得div"wrapper"中的最后一个超链接.但在另一个网站上,我只是关闭连接.请帮忙.
Private Function getText() As String
Dim web = New HtmlWeb()
Dim html As HtmlDocument
html = web.load("http://some-website.com")
Dim lastLink = html.DocumentNode.SelectSingleNode("//div[@id='wrapper']//a[last()]")
If lastLink IsNot Nothing Then
Return lastLink.InnerHtml
Else
Return "nothing found"
End If
End Function
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
label4.Text = getText()
End Sub
Run Code Online (Sandbox Code Playgroud) 我有一个表client,我需要复制一列的值并将其粘贴到同一行中的另一列.
这是当前的数据:
ClientID Name DuplicateName
1 NULL name1
2 NULL name2
3 NULL name3
Run Code Online (Sandbox Code Playgroud)
我希望它从中获取数据duplicateName并将其放入Name:
ClientID Name DuplicateName
1 name1 name1
2 name2 name2
3 name3 name3
Run Code Online (Sandbox Code Playgroud) 我使用了一个流行的在线代码转换器从VB转到C#,C#没有在这个for循环上工作.任何C#专家都能看到问题吗?
更具体地说,智能感知告诉我CustomerRoles()不能像方法那样使用.它在VB中工作正常.
VB:
Dim Roles As New List(Of String)
For x As Integer = 0 To EngineContext.Current.Resolve(Of IWorkContext)().CurrentCustomer.CustomerRoles().Count - 1
Roles.Add(EngineContext.Current.Resolve(Of IWorkContext)().CurrentCustomer.CustomerRoles(x).Name)
ddlRoles.Items.Add(EngineContext.Current.Resolve(Of IWorkContext)().CurrentCustomer.CustomerRoles(x).Name)
Next
Run Code Online (Sandbox Code Playgroud)
C#(这不起作用):
List<string> Roles = new List<string>();
for (int x = 0; x <= EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.CustomerRoles().Count - 1; x++) {
Roles.Add(EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.CustomerRoles(x).Name);
ddlRoles.Items.Add(EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.CustomerRoles(x).Name);
}
Run Code Online (Sandbox Code Playgroud) 我使用代码转换器从VB转到C#,我在c#中遇到错误.特别是,错误Item等等string.join(",", Flop.ToArray).错误说它不包含定义item但它在VB中有效.
VB
Dim Flop As New List(Of String)
For x As Integer = 0 To Dataset9.Tables(0).Rows.Count - 1 'ROWS
Flop.Add(Dataset9.Tables(0).Rows(x).Item("Id"))
Next
strAllRoleNames = String.Join(",", Flop.ToArray)
Run Code Online (Sandbox Code Playgroud)
C#
List<string> Flop = new List<string>();
for (int x = 0; x <= Dataset9.Tables[0].Rows.Count - 1; x++)
{
Flop.Add(Dataset9.Tables[0].Rows[x].Item["Id"]);
}
strAllRoleNames = string.Join(",", Flop.ToArray);
Run Code Online (Sandbox Code Playgroud) 我正在使用datediff获取 2 组或更多组日期之间的差值总和,aDateStart并且aDateEnd. 结果应该是 7.75,但问题是它四舍五入到 7.00 并Decimal(9,2)在除以 60 部分后将其存储在数据库列中。如果我从SQL查询中去掉“/60”,结果是465.00,分分钟是正确的,但我希望数据库存储7.75
我得到了正确的秒数,但是当我除以 60 时,它会四舍五入为 7.00。
数据:
orderId AdminId aStartDate aEndDate
-----------------------------------------------------------------------
1 1 2021-04-02 08:00:00.000 2021-04-02 11:30:00.000
1 1 2021-04-02 08:00:00.000 2021-04-02 12:15:00.000
Run Code Online (Sandbox Code Playgroud)
存储过程的相关部分:
ALTER PROCEDURE [dbo].[sp_updateManagerStatus]
@AdminId int,
@OrderId int,
@Id int,
@Count1 decimal(9,2) OUTPUT
SELECT
@Count1 = SUM(DATEDIFF(MINUTE, aStartDate, aEndDate) / 60)
FROM
Assignment
WHERE
OrderId = @OrderId AND AdminId = @AdminId
BEGIN
UPDATE JobSite
SET SiteActualTime = @Count1
WHERE Id = …Run Code Online (Sandbox Code Playgroud) 谁能帮助我在 2.8 版本中获得视图的客户角色?我尝试过工作上下文,但错误提示“当前上下文中不存在工作上下文”。我有下面的代码,但它不起作用..
@model BoardsIndexModel
@using Nop.Core.Infrastructure;
@using Nop.Services.Helpers;
@using Nop.Web.Models.Boards;
@using Nop.Core.Domain.Customers;
@using Nop.Services.Customers;
@if (Roles.IsUserInRole("Administrators"))
{
Do that;
}
else
{
Do this;
}
Run Code Online (Sandbox Code Playgroud)