c#

作者: 七七三三 | 来源:发表于2019-09-29 16:06 被阅读0次

    1.连接字符串

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using MySql.Data.MySqlClient;
    using System.Data.OleDb;
    
        private DataSet sqlMethod(string sql)
        {
            MySqlConnection conn = new MySqlConnection("Database=dream;Data Source=localhost;User Id=root;Password=123456");
            MySqlDataAdapter da = new MySqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            conn.Open();
            da.Fill(ds);
            conn.Close();
            return ds;
        }
        private int sqlMethodNoDataset(string sql)
        {
            MySqlConnection conn = new MySqlConnection("Provider=MySqlOLEDB;; Database=dream;Data Source=localhost;User Id=root;Password=123456");
            conn.Open();
            MySqlCommand cmd = new MySqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = sql;
            int result = cmd.ExecuteNonQuery();
            conn.Close();
            return result;
        }
    

    2.cookie的创建与删除
    3.判断是否存在cookie

           if (Request.Cookies["user_id"] == null)
            {
                //Response.Write("<Script>alert(\"请先登录\")</script>");
                //Response.Redirect("index_login.aspx");
            }
            else
            {
                HttpCookie hc = Request.Cookies["user_id"];
                user_id = hc.Value;
            }
    

    相关文章

      网友评论

          本文标题:c#

          本文链接:https://www.haomeiwen.com/subject/ojreuctx.html