用asp.net串連資料庫的登陸代碼

來源:互聯網
上載者:User
用asp.net串連資料庫,做登入頁面,怎麼弄呢。
辦法:
using System.Data.SqlClient;//記得加引用private bool Login(string sno,string sname){SqlConnection con = new SqlConnection("Data Source=資料庫連接;Initial Catalog=Stu_table;User ID=sa;Password=123456789");con.Open();string sql = string.Format("select count(*) from Student where Sno='{0}' and Sname='{1}'",sno,sname);//這裡你自己改改了,不知道你用什麼登陸的,帳號密碼不知道你用什麼欄位,暫時認為你用學號跟姓名登陸SqlCommand com = new SqlCommand(sql, con);int flag =(int) com.ExecuteScalar();con.Close();if (flag > 0){return true;}return false;}


//把上面的代碼放在login.aspx.cs裡面,你哪裡登陸就調用這個函數,傳登陸帳號跟密碼進來就行了.
//登陸成功就返回true,否則就返回false
//登陸成功你可以用下列語句跳轉到你那個頁面
Response.Redirect("裡面你跳轉的Url");
//登陸失敗你可以提示 
Response.Write("<script> alert('帳號密碼錯誤');</script>");
//上面這個邏輯自己寫不出來的,那就真沒辦法了,小孩子都會了
//資料庫連接:這個你自己改,一般用 . 表示,你也可以自己開你的資料庫看。




問題:怎麼實現滑鼠跟隨事件與捲軸的綁定。
滑鼠跟隨事件在給了body高度之後,想要跟隨的圖片到一定位置之後就不在變化了,是為什麼。
代碼如下:
<!DOCTYPE html><html><head><meta charset="utf-8"><title>廣告</title></head><body style="height:1500px"><script type="text/javascript">    function badAD(html){        var gg=document.body.appendChild(document.createElement('div'));        gg.style.cssText="border:1px solid pink;background:#000;position:absolute;";        gg.innerHTML=html||'This is bad idea!';        var c=gg.appendChild(document.createElement('span'));        c.innerHTML="×";        c.style.cssText="position:absolute;right:4px;top:15px;cursor:pointer;color:red;font-weight:bold;";        c.onclick=function (){        document.onmousemove=null;            this.parentNode.style.left='-99999px'        };        document.onmousemove=function (e){            e=e||window.event;            var x=e.clientX,y=e.clientY;            setTimeout(function() {                if(gg.hover)return;                gg.style.left=x+5+'px';                gg.style.top=y+5+'px';            },120)    }        gg.onmouseover=function (){            this.hover=true        };        gg.onmouseout=function (){            this.hover=false        }    }    badAD('"一個連結"; "><img src="4.png"></a>')    </script></body></html>


回答:
看這裡:var x=e.pageX,y=e.pageY;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.