两个小问题,请求帮助?

goodluck20131313 2011-07-05 10:31:50
在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 '%输入单号/发货方/收货方/装车号/备注查询%')%'。。。。。。。。。。。。。。。。。。。。。
...全文
117 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
goodluck20131313 2011-07-05
  • 打赏
  • 举报
回复
输入的是string 内容,但是无法字符串不正确
q107770540 2011-07-05
  • 打赏
  • 举报
回复
1: string dd = ddlstate.SelectedValue==null?"":ddlstate.SelectedValue.ToString();

2: 你拼接的就是STRING字符串 难道输出的不是STRING内容 ?
想要查询结果 要连接数据库 去库中执行此SQL语句
bdmh 2011-07-05
  • 打赏
  • 举报
回复
跟踪吧,不定在哪没清除之前的数据,或者循环赋值了
alluserinfo 2011-07-05
  • 打赏
  • 举报
回复
来过!!!!!!!!!!!!!!!!!!!!!!!!!!
woshiliourun 2011-07-05
  • 打赏
  • 举报
回复
全部私有滴?~····
内容概要:本文系统研究了构网型变流器的正负序阻抗解耦特性及其在弱电网环境下的稳定性表现,重点依托Matlab/Simulink仿真平台,构建了详细的阻抗数学模型,设计了解耦控制策略,并采用小信号扫频法进行频域辨识与稳定性验证。研究深入探讨了构网型变流器与传统跟网型逆变器在正负序阻抗特性上的本质差异,结合虚拟同步发电机(VSG)等先进控制技术,分析其在抑制宽频带振荡、削弱锁相环动态耦合等方面的优越性。文中不仅提供了完整的仿真模型与MATLAB代码实现,还整合了光伏、风电、储能、微电网等多类新能源系统的阻抗建模与稳定性分析资源,形成了一套面向新型电力系统稳定性的综合性技术资料体系,具有较强的科研复现与工程参考价值。; 适合人群:面向具备电力电子、电力系统自动化、新能源并网等专业背景的研究生、高校教师及工程技术人员,特别适用于从事阻抗建模、小干扰稳定性分析、宽频振荡机理研究以及撰写高水平学术论文的科研工作者。; 使用场景及目标:①掌握构网型变流器正负序阻抗建模与扫频辨识的仿真方法;②深入理解VSG等构网型控制在弱电网中提升稳定性的内在机理;③复现顶刊论文中的阻抗分析流程与稳定性判据应用;④利用提供的成熟模型与代码加速科研进程,支撑课题研究与学术成果产出。; 阅读建议:建议结合文中提供的Simulink模型与MATLAB代码,按照“理论建模—仿真搭建—扫频激励—频响提取—Nyquist判据分析”的完整流程进行实践操作,重点关注扫频信号的注入方式、频率范围设置及阻抗曲线的物理意义解读,并参考博士论文复现案例深化对复杂动态耦合问题的理解。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧