本文介绍了我如何... Dropdownlist过滤器在ASP.net中使用层架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
国家/地区aCountry = 新国家/地区();
int countryId = aCountry.CountryId;
string quary = SELECT StateId,StateName FROM tCountryState WHERE countryId =' + countryId + ';
SqlConnection con = new SqlConnection(连接);
con.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(quary,con);
da.Fill(ds);
con.Close();
return ds;
[我的字符串问题在哪里? ????????????????????????????????????????????????????????????????????????????????????????????????? b $ b
国家/地区aCountry = 新国家/地区();
int countryId = aCountry.CountryId;
而 aCountry
是 new Country();
,你怎么会得到 aCountry.CountryId
,它可能会返回null。
你的第二个错误是:
string quary = SELECT StateId,StateName FROM tCountryState WHERE countryId =' + countryId + ';
here countryId
是 int ,您也没有将其转换为 string 。你应该写成:
string quary = SELECT StateId,StateName FROM tCountryState WHERE countryId =' + Convert.ToString(countryId)+ ';
Country aCountry=new Country(); int countryId = aCountry.CountryId; string quary = "SELECT StateId,StateName FROM tCountryState WHERE countryId='"+countryId+"'"; SqlConnection con = new SqlConnection(connection); con.Open(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(quary, con); da.Fill(ds); con.Close(); return ds;
[Where my string problem?????????????]
解决方案
这篇关于我如何... Dropdownlist过滤器在ASP.net中使用层架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!