zoukankan      html  css  js  c++  java
  • 网站积累

    数据库连接:
    <appSettings/>
    <connectionStrings>
        <add name="conn" connectionString="Data Source=FUCK-PC\SQLEXPRESS;Initial Catalog=jxcSystem;Integrated Security=True"/>
      </connectionStrings>
     <system.web>
        <!--出错时跳转页-->
        <customErrors mode="On" defaultRedirect="~/错误页.htm"></customErrors>

    构造函数连接数据库:

     public SqlHelper()           {             string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;             conns = new SqlConnection(conn);            }       

    打开数据库连接:        

    private SqlConnection Getconn()         {             if (conns.State == ConnectionState.Closed)             {                 conns.Open();               }             return conns;         }

    执行带参数的增删改:

    public int ExecuteNonQuery(string cmdText, SqlParameter[] paras, CommandType ct)         {             int res;             using (cmd = new SqlCommand(cmdText, Getconn()))             {                 cmd.CommandType = ct;                 cmd.Parameters.AddRange(paras);                 res = cmd.ExecuteNonQuery();             }             return res;         }

    执行带参数的查询:

    public DataTable Execuquery(string cmdText, SqlParameter[] paras, CommandType ct)         {             DataTable dt = new DataTable();             using (cmd = new SqlCommand(cmdText, Getconn()))             {                 cmd.CommandType = ct;                 cmd.Parameters.AddRange(paras);                 sdr = cmd.ExecuteReader();                 dt.Load(sdr);                 sdr.Close();                 return dt;             }         }

    错误页js出错后返回:

       <script type="text/javascript">     var i=5;     var intervalId;     intervalId=setInterval("fun()",1000);     function fun()     {     if(i==0){     window.location.href="首页.aspx";     clearInterval(intervalId);     }     document.getElementById("mes").innerHTML=i;     i--;     }     </script>

    获得当前系统时间:

    <script type="text/javascript">     function fun(){     var date=new Date();     var hh=date.getHours();     var mm=date.getMinutes();     var ss=date.getSeconds();     document.getElementById("lbl1").value="当前时间:"+hh+":"+mm+":"+ss;     setTimeout("fun()",1000);     }     </script>

    链接css文件:     <link href="css/firstPage.css" rel="stylesheet" type="text/css" />

  • 相关阅读:
    Jmeter Ant Task如果报告中有错误,在邮件内容里面直接显示出来 系列2
    自动化测试的点点滴滴经验积累
    Java中通过SimpleDateFormat格式化当前时间:/** 输出格式:20060101010101001**/
    Good Bye 2015 A
    Codeforces Round #337 (Div. 2)B
    Codeforces Round #337 (Div. 2) A水
    hdu 1698 线段树 区间更新 区间求和
    hdu 1166线段树 单点更新 区间求和
    HDU2841 (队列容斥)
    15ecjtu校赛1006 (dfs容斥)
  • 原文地址:https://www.cnblogs.com/msdncrazy/p/2968880.html
Copyright © 2011-2022 走看看