获取数据库的表中一个值

把这个19 转成int类型

                List<object> one = new List<object>();
                one.Add(new XQsys.BLL.News().SelectNewslastID());
                int id = Convert.ToInt32(one[0]);

方法二:

                SqlConnection conn = sqlhelp.createcon();
                SqlCommand com = new SqlCommand();
                com.CommandType = CommandType.Text;
                com.CommandText = "select UserId from [user] where username=\'" + username + "\'";
                com.Connection = conn;
                conn.Open();
                object obj = com.ExecuteScalar();
                conn.Close();
                int id = Convert.ToInt32(obj);
                Session["userid"] = id;

貌似方法一与方法二都是一样的,仅个人观点

posted on 2012-03-25 00:38  譕?  阅读(183)  评论(0编辑  收藏  举报

导航