SqlCommand cmd = new SqlCommand("select folderlocation from fsfilestorage
where id='"+sessionid+"'", con);
SqlDataReader reader1 = cmd.ExecuteReader();
reader1.Read();
string folder = string.Empty;
folder = reader1.GetString(0);
答案 0 :(得分:0)
使用SqlCommand.ExecuteScalar
从db获取单个值并将其添加到Response.Cookies
var folder=cmd.ExecuteScalar().ToString();
HttpCookie myCookie = new HttpCookie("folder");
myCookie["FolderPath"] = folder;
myCookie.Expires = DateTime.Now.AddDays(1d);
Response.Cookies.Add(myCookie);