日期:2014-05-17 浏览次数:20468 次
private const string SQL_SELECT_USER = "SELECT ID,OId,Access,User_name,Img,CARDs,NAMEs From info WHERE ID = @Id"; private const string PARM_Id = "@Id"; public ModelInfo info(int id) { ModelInfo info= new ModelInfo(); SqlParameter parm = new SqlParameter(PARM_Id, SqlDbType.Int); parm.Value = id; using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_USER, parm)) { account = new ModelInfo (rdr.GetInt32(0), rdr.GetString(1), rdr.GetString(2), rdr.GetString(3), rdr.GetString(4), rdr.GetString(5),rdr.GetString(6)); } return id; 数据字段 ID int OID varchar(100) 可为空 access varchar(100) 可为空 User_name varchar(100) 可为空 Img varchar(100) 可为空 cards varchar(100) 可为空 name varchar(100) 可为空 string id="123"; ModelInfo info= SQLServer.info(Int32.Parse(Id));
string s1 = dr.GetString(1); string s2 = dr[1].ToString();