标签:cut nbsp sqlite exe reader open 本地变量 select code
获得数据库指定字段的值,赋给本地变量
如下,获得userinfo数据表里的字段"userid"、"orgid",
string userid=""; string orgid=""; using (SQLiteConnection con = new SQLiteConnection(Constants.DATA_SOURCE)) { con.Open(); using (SQLiteCommand cmd = new SQLiteCommand()) { cmd.Connection = con; cmd.CommandText = string.Format("select * from userinfo t "); using (SQLiteDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { while(dr.Read()) { userid = dr["userid"].ToString(); orgid = dr["orgid"].ToString(); } } } }
标签:cut nbsp sqlite exe reader open 本地变量 select code
原文地址:http://www.cnblogs.com/Donnnnnn/p/6023421.html