求助,SQL2005连接问题
using System;using
using System.Data;
using System.Configuration;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _select : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.; database=select;uid=sa;pwd=;");
con.Open;
SqlCommand cmd = new SqlCommand("select * from provence", con);
SqlDataReader sdr = cmd.ExecuteReader();
this.ddlPro.DataSource = sdr;
this.ddlPro.DataTextField = "ProName";
this.ddlPro.DataValueField = "ProID";
this.ddlPro.DataBind();
sdr.Close();
//city的绑定
SqlCommand citycmd = new SqlCommand("select * from City where ProID=" + this.ddlPro.SelectedValue, con);
SqlDataReader sdrcity = citycmd.ExecuteReader();
this.ddlCity.DataSource = sdrcity;
this.ddlCity.DataTextField = "CityName";
this.ddlCity.DataValueField = "CityID";
this.ddlCity.DataBind();
sdrcity.Close();
con.Close();
}
}
在con.Open;出现 CS0201: 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
这是怎么回事?怎样才能解决?