protected void Button1_Click(object sender, EventArgs e)
我們提供的服務(wù)有:成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、中方ssl等。為數(shù)千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的中方網(wǎng)站制作公司
{
if (TextBox1.Text == "" || TextBox2.Text == "")
{
Response.Write("scriptalert('用戶名或密碼不能為空!')/script"); //提示對(duì)話框
}
else
{
string ConStr = "server=(local);user id=sa;pwd=123456;database=userdb";
SqlConnection con = new SqlConnection(ConStr);
string SqlStr = "select * from mymember where sname = '" + TextBox1.Text + "' and spwd = '" + TextBox2.Text + "'"; //Select查詢語(yǔ)句
SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
con.Open(); //打開連接
DataSet ds = new DataSet();
ada.Fill(ds);
if (ds.Tables[0].Rows.Count 0)
{
Session["username"] = TextBox1.Text;
Response.Redirect("index.aspx");
}
else
{
Response.Write("scriptalert('用戶名或密碼錯(cuò)誤,請(qǐng)重新登錄!')/script");
}
} //綁定GridView控件
}
vb登陸程序源代碼\x0d\x0a\x0d\x0a你可以這樣做建一個(gè)模塊在里面輸入下列\(zhòng)x0d\x0aPublic conn As ADODB.Connection\x0d\x0aSub main()\x0d\x0a Set conn = New ADODB.Connection\x0d\x0a conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _\x0d\x0a + "User ID=sa;password=sa;Initial Catalog=您的數(shù)據(jù)庫(kù)名;Data Source=127.0.0.1"\x0d\x0a conn.Open\x0d\x0afrom1.Show ’登錄界面\x0d\x0aEnd Sub\x0d\x0a\x0d\x0a再在登錄界面“確定”下寫入如下代碼:\x0d\x0aPrivate Sub Command1_Click()\x0d\x0a If id.Text = "" Then\x0d\x0a MsgBox "用戶名不能為空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0a id.SetFocus\x0d\x0a Exit Sub\x0d\x0a End If\x0d\x0a If password.Text = "" Then\x0d\x0a MsgBox "密碼不能為空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0a password.SetFocus\x0d\x0a Exit Sub\x0d\x0a End If\x0d\x0a\x0d\x0a Dim strSQl As String\x0d\x0a strSQl = "select * from Users where users_name='" Trim$(id.Text) "' and password='" Trim$(password.Text) "' "\x0d\x0a \x0d\x0a Dim str As New ADODB.Recordset\x0d\x0a Set str = New ADODB.Recordset\x0d\x0a str.CursorLocation = adUseClient\x0d\x0a str.Open strSQl, conn, adOpenStatic, adLockReadOnly\x0d\x0a \x0d\x0a With str\x0d\x0a If .State = adStateOpen Then .Close\x0d\x0a .Open strSQl\x0d\x0a If .EOF Then\x0d\x0a Try_times = Try_times + 1\x0d\x0a If Try_times = 3 Then\x0d\x0a MsgBox "您已經(jīng)三次嘗試進(jìn)入本系統(tǒng),均不成功,系統(tǒng)將自動(dòng)關(guān)閉", vbOKOnly + vbCritical, "警告"\x0d\x0a Unload Me\x0d\x0a Else\x0d\x0a MsgBox "對(duì)不起,用戶名不存在或密碼錯(cuò)誤 !", vbOKOnly + vbQuestion, "警告"\x0d\x0a id.SetFocus\x0d\x0a id.Text = ""\x0d\x0a password.Text = ""\x0d\x0a End If\x0d\x0a Else\x0d\x0a \x0d\x0a Unload Me\x0d\x0a \x0d\x0a Form2.Show ’登錄進(jìn)入的另一個(gè)界面\x0d\x0a \x0d\x0a End If\x0d\x0a End With\x0d\x0a\x0d\x0aEnd Sub
你的算法非常的傻,劇慢沒有可用性。
用一個(gè)sql查詢 查找 密碼=輸入密碼,用戶名等于輸入的用戶的記錄,找到了即登錄..
dim oRd as new recordset
dim db as connection ' 用db打開數(shù)據(jù)庫(kù)
dim sa as string
sa=”select * from table where username='" txtDIM_Username.Text _
"' and userpassword='" txtDIM_Password.Text "'"
ord.open sa,db
if ord.eof() or ord.bof()
‘未找到,不能登錄
else
'找到 登錄成功....
endif
哈哈簡(jiǎn)單哪
第一步:登陸網(wǎng)頁(yè)代碼
第二步:登陸以后判斷是否登陸成功
有兩種方法:1.獲取網(wǎng)頁(yè)代碼,判斷網(wǎng)頁(yè)字符有無(wú)”登陸成功”字樣
源代碼:
2.就是判斷網(wǎng)頁(yè)是否跳轉(zhuǎn)到了某一頁(yè)
源代碼:
兩種方法結(jié)合起來用,可以判斷網(wǎng)頁(yè)是否無(wú)法連接
分享標(biāo)題:vb點(diǎn)虐
網(wǎng)絡(luò)登陸頁(yè)面 vbnet登錄界面連接access
網(wǎng)站鏈接:http://www.yijiale78.com/article10/ddgejgo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、做網(wǎng)站、軟件開發(fā)、用戶體驗(yàn)、網(wǎng)站建設(shè)、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)