两个小问题,请求帮助?
在WINFROM 中,问题一,提示:未将对象引用设置到对象的实例
private void Bindstate()
{
List<ListItem> items = new List<ListItem>();
items.Add(new ListItem("0", "所有状态"));
items.Add(new ListItem("1", "审核"));
items.Add(new ListItem("2", "结算"));
ddlstate.DisplayMember = "Text"; //显示
ddlstate.ValueMember = "Value"; //值
ddlstate.DataSource = items;
}
private void listFrm_Load(object sender, EventArgs e)
{
Bindstate();
BindData();
}
private void BindData()
{
string dd = ddlstate.SelectedValue.ToString();//提示:未将对象引用设置到对象的实例
}
--------------------------------------------
-------------------------------------------
问题2:
以下主要用于组合查询
DataTable dt = new DataTable();
if (ddlnetwork.SelectedValue.ToString() != "0")
{
string network=ddlnetwork.SelectedValue.ToString();
sql2 = sql2 + "and a.chitty_network='"+network+"'";
}
if (txtkey.Text != "")
{
string key = txtkey.Text.Trim();
sql2 = sql2 + "and ((select corp_name from p_corp where corp_id=a.chitty_corp) like '%"+key+"%' or (select corp_name from p_corp where corp_id=a.chitty_corp2) like '%"+key+"%')";
}
string sql = "select a.* from p_sale a where 1=1" + sql2;
MessageBox.Show(sql);
为什么输出的是相当长的一字符串:select a.* from p_sale a where 1=1and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='1'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%输入单号/发货方/收货方/装车号/备注查询%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%输入单号/发货方/收货方/装车号/备注查询%')%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%输入单号/发货方/收货方/装车号/备注查询%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%输入单号/发货方/收货方/装车号/备注查询%')%')%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%输入单号/发货方/收货方/装车号/备注查询%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%输入单号/发货方/收货方/装车号/备注查询%')%'。。。。。。。。。。。。。。。。。。。。。
private void Bindstate()
{
List<ListItem> items = new List<ListItem>();
items.Add(new ListItem("0", "所有状态"));
items.Add(new ListItem("1", "审核"));
items.Add(new ListItem("2", "结算"));
ddlstate.DisplayMember = "Text"; //显示
ddlstate.ValueMember = "Value"; //值
ddlstate.DataSource = items;
}
private void listFrm_Load(object sender, EventArgs e)
{
Bindstate();
BindData();
}
private void BindData()
{
string dd = ddlstate.SelectedValue.ToString();//提示:未将对象引用设置到对象的实例
}
--------------------------------------------
-------------------------------------------
问题2:
以下主要用于组合查询
DataTable dt = new DataTable();
if (ddlnetwork.SelectedValue.ToString() != "0")
{
string network=ddlnetwork.SelectedValue.ToString();
sql2 = sql2 + "and a.chitty_network='"+network+"'";
}
if (txtkey.Text != "")
{
string key = txtkey.Text.Trim();
sql2 = sql2 + "and ((select corp_name from p_corp where corp_id=a.chitty_corp) like '%"+key+"%' or (select corp_name from p_corp where corp_id=a.chitty_corp2) like '%"+key+"%')";
}
string sql = "select a.* from p_sale a where 1=1" + sql2;
MessageBox.Show(sql);
为什么输出的是相当长的一字符串:select a.* from p_sale a where 1=1and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='1'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%输入单号/发货方/收货方/装车号/备注查询%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%输入单号/发货方/收货方/装车号/备注查询%')%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%输入单号/发货方/收货方/装车号/备注查询%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%输入单号/发货方/收货方/装车号/备注查询%')%')%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%select a.* from p_sale a where 1=1and a.sale_network='System.Data.DataRowView'and ((select corp_name from p_corp where corp_id=a.sale_corp) like '%输入单号/发货方/收货方/装车号/备注查询%' or (select corp_name from p_corp where corp_id=a.sale_corp2) like '%输入单号/发货方/收货方/装车号/备注查询%')%'。。。。。。。。。。。。。。。。。。。。。
...全文
相关推荐
详解AOP与Filter拦截请求打印日志实用例子
主要介绍了详解AOP与Filter拦截请求打印日志实用例子,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
跨域请求解决方案
ajax跨域请求解决方案。有详细配置方案,轻松解决ajax请求数据是的跨域问题。
php通过隐藏表单控件获取到前两个页面的url
主要介绍了php通过隐藏表单控件获取到前两个页面的url,此法比较实用,需要的朋友可以参考下
fetch GET请求带参数[代码]
本文介绍了如何使用fetch方法发起GET请求并携带参数。fetch是一种现代的网络请求API,广泛应用于前端开发中。文章详细说明了如何构造GET请求的URL,包括在URL中添加查询参数的方法,以及如何处理这些参数。通过示例代码,读者可以清晰地了解fetch GET请求的实现过程,适用于需要从服务器获取数据并传递参数的场景。
Java模拟HTTP Get Post请求 轻松实现校园BBS自动回帖
主要介绍了Java模拟HTTP Get Post请求,轻松实现校园BBS自动回帖,感兴趣的小伙伴们可以参考一下


