private void button1_Click(object sender, EventArgs e)
{
string sk = SearchKey.Text.ToString().Trim();
data dataconn = new data();
string connstr = dataconn.connstr.ToString();
SqlCeConnection conn = new SqlCeConnection(connstr);
string query = "select EntID,jgmc from Ent where jgmc like '%"+sk+"%'";
SqlCeDataAdapter da = new SqlCeDataAdapter(query, conn);
DataSet ds = new DataSet("entid");
da.Fill(ds, "entname");
this.EntList.DataSource = ds.Tables["entname"];
this.EntList.DisplayMember = "jgmc";
this.EntList.ValueMember = "EntID";
}
class data
{
static string sPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString());
public string connstr = "Data Source=" + sPath + "//WzzlMobileData.sdf";
}