//sdf数据库文件所在路径
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
//
string destConnString = @"Data Source=" + path + "\\vstream.sdf";
SqlCeConnection destConnection = new SqlCeConnection(destConnString);
destConnection.Open();
IList list = new List();
string sql = "select * from posuser";
DataSet ds = new DataSet();
SqlCeCommand cmd = new SqlCeCommand(sql, destConnection);
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
da.Fill(ds);
DataTable table = ds.Tables[0];
foreach (DataRow row in table.Rows)
{
Posuser posuer = new Posuser();
posuer.Posuser_id = (int)row["Posuser_id"];
posuer.Is_enabled = (byte)row["Is_enabled"];
posuer.Is_admin = (byte)row["Is_admin"];
posuer.Posuser_pin = (string)row["Posuser_pin"];
posuer.Posuser_name = (string)row["Posuser_name"];
if (row["Posuser_idnumber"] is DBNull)
{
posuer.Posuser_idnumber = "";
}
else
{
posuer.Posuser_idnumber = (string)row["Posuser_idnumber"];
}
list.Add(posuer);
}
destConnection.Close();
复制代码
改了。我在windows下运行bin目录里的exe文件,查出来的值还是null!!!