小编66M*_*Mhz的帖子

添加SqlParameter以绑定LIKE'%@ x%'

我在获取以下代码以正确添加SqlCommand参数时遇到问题@vendor.由于某种原因,传递的查询似乎总是:

select TOP 500 * 
from [mike_db].[dbo].[na_pe_sql_import] 
where vendname like '%@vendor%';
Run Code Online (Sandbox Code Playgroud)

如果我像这样设置查询,它可以工作,但我知道这是不好的做法:

string strQuery = "select TOP 500 * from [mike_db].[dbo].[na_pe_sql_import] where vendname like '%"+txt_search.Text.ToString()+"%';";
Run Code Online (Sandbox Code Playgroud)

这是代码:

    protected void Search_Click(object sender, EventArgs e)
    {   
        string search = txt_search.Text.ToString();
        String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["mike_db"].ConnectionString;

        SqlConnection con = new SqlConnection(strConnString);
        con.Open();

        string strQuery = "select TOP 500 * from [mike_db].[dbo].[na_pe_sql_import] where vendname like '%@vendor%';";

        cmd = new SqlCommand(strQuery, con);
        cmd.Parameters.AddWithValue("vendor", search);

        txt_search.Text = string.Empty;

        DataSet ds = new DataSet();

        da …
Run Code Online (Sandbox Code Playgroud)

c# asp.net parameters sqlcommand

6
推荐指数
1
解决办法
6805
查看次数

使用BeautifulSoup find_all从最后一个元素获取内容

我正在尝试从find_all创建的列表中的最后一个div中提取内容.

post_content = soup.find_all('div',{'class': 'body_content_inner'})

存储以下文本:

[<div class="body_content_inner">
 post #1 content is here
 </div>, <div class="body_content_inner">
 post #2 content is here
 </div>]
Run Code Online (Sandbox Code Playgroud)

我想提取存储在最后一个div标签中的文本,但我不确定如何迭代 post_content

python beautifulsoup

3
推荐指数
2
解决办法
1万
查看次数

如何使用Math.Max,Math.Min找到三个最大和三个最小的化学品

我正在使用Math.Max和Math.Min来查找以下代码中的最大和最小小数:

decimal[] numbers = { d1, d2, d3, d4, d5, d6, d7, d8, d9, d10 };
decimal biggestNumber = numbers.Max();
decimal lowestNumber = numbers.Min();
lblS1Val.Text = biggestNumber.ToString();
lblO1Val.Text = lowestNumber.ToString();
Run Code Online (Sandbox Code Playgroud)

我想找到三个最大和三个最小的数字.我可以用Math.Max/Min做到吗?

c# asp.net

2
推荐指数
2
解决办法
429
查看次数

标签 统计

asp.net ×2

c# ×2

beautifulsoup ×1

parameters ×1

python ×1

sqlcommand ×1