简体   繁体   English

如何在sql查询中从db中划分列上的textBox?

[英]How to divide textBox on column from db in sql query?

How to divide textBox8 on value of Price如何根据价格的值划分 textBox8

Int32 readSearch2 = Convert.ToInt32(textBox8.Text);
SqlCommand command = new SqlCommand("SELECT [Price] FROM [Products] ", sqlConnection);

You can do it by adding a SqlCommand Parameter, but as I mentioned in the comments, note that you may have many records in Products table and it will affect all prices (for all records):您可以通过添加 SqlCommand 参数来实现,但正如我在评论中提到的,请注意,您可能在Products表中有很多记录,并且它会影响所有价格(对于所有记录):

SqlCommand command = new SqlCommand("SELECT @val/[Price] as Price FROM [Products] ", sqlConnection);

cmd.Parameters.Add("@val", SqlDbType.Float).Value = double.Parse(TextBox8.Text);

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

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