从多个组合框中获取所选信息的产品ID [英] Get the Product ID of the selected information from multiple combo boxes

查看:102
本文介绍了从多个组合框中获取所选信息的产品ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:


combobox0(产品ID)= ?
combobox1(产品类型)=玻璃
combobox2(产品子类型)=商品玻璃
combobox3(产品名称)=透明浮法玻璃
combobox4(产品尺寸)= 12 x 12英寸

您可以改善代码吗?

example:


combobox0(product id) = ?
combobox1(product type) = Glass
combobox2(product subtype) = Commodity Glass
combobox3(product name)= Clear Float Glass
combobox4(product dimension) = 12 x 12 in

can you improve the code:

string query = "select * from RawMat WHERE ProductName = '" +  cboproductname.SelectedItem.ToString() + "'";

推荐答案

是.

1)不要使用"SELECT * FROM ..."-而是指定您的字段.
2)不要连接字符串以构建SQL命令.它使您对意外或蓄意的SQL注入攻击敞开大门,这可能会破坏整个数据库.改为使用参数化查询.
Yes.

1) Don''t use "SELECT * FROM..." - specifiy your fields instead.
2) Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.


这篇关于从多个组合框中获取所选信息的产品ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆