//构见sdsall的SQL命令字符串
var str1="SELECT * FROM [cxsq] ";
if (ddlsqs.Value != "全省")
str1 = str1 + " where [xiaqu]=" + "'" + ddlsqs.Value + "'";
if (ddlxsq.Value != "全部县市区")str1 = str1 + " and [xsq]=" + "'" + ddlxsq.Value + "'";
if (ddlstatus.Value != "全部")
str1 = str1 + " and [status]=" + "'" + ddlstatus.Value + "'";
if (ddlyear.Value != "全部")str1 = str1 + " and CONVERT(varchar(4), appdate, 23) =" + "'" + ddlyear.Value + "'";
str1 = str1 + " and [kind]='改名'";
string connString = "server=.; uid=skdb; pwd=skdb; database=skdb";
SqlConnection conn = new SqlConnection(connString); SqlDataAdapter sda = new SqlDataAdapter(str1, conn);DataTable result = new DataTable();
sda.Fill(result);gvsqls.DataSource = result;
gvsqls.DataBind();