 |
|
|
 |
 |
|
Code (Login.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ThaiCreate Login (ASP.NET & Login Form)</title>
</head>
<body>
<form id="frmMain" runat="server">
<div>
<asp:Label ID="lblUsername" runat="server" Text="Username"></asp:Label>
<asp:TextBox ID="txtUsername" runat="server"></asp:TextBox> <br />
<asp:Label ID="lblPassword" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:Button ID="btnLogin" runat="server" Text="Login" />
<asp:Label ID="lblMsg" runat="server"></asp:Label></div>
</form>
</body>
</html>
Code (Login.aspx.vb)
Imports System.Data.OleDb
Imports System.Data
Partial Class Login
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Onload Event
End Sub
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim objConn As OleDbConnection
Dim dtAdapter As OleDbDataAdapter
Dim dt As New DataTable
Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("database/mydatabase.mdb") & ";"
objConn = New OleDbConnection(strConnString)
objConn.Open()
Dim strSQL As String
strSQL = "SELECT * FROM user WHERE Username = '" & Me.txtUsername.Text & "'" & _
" AND Password = '" & Me.txtPassword.Text & "' "
dtAdapter = New OleDbDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
If dt.Rows.Count <= 0 Then
Me.lblMsg.Text = "Invalid Username & Password"
Else
Response.Redirect("Wecome.aspx")
End If
End Sub
End Class
|
 |
 |
 |
 |
Date :
2009-08-08 22:28:46 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันเอ่อเร่อตรง Server อะครับผมเขียน Vb อะครับ
|
 |
 |
 |
 |
Date :
2009-08-09 21:33:26 |
By :
ธนารักษ พุทธา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

อยากได้โค๊ดเกี่ยวกับการเปลี่ยนรหัสผ่านอะคับช่วยทีต้องเขียนโค๊ดอย่างไรคับดังรูป VB.Net
เมื่อคลิกยืนยันให้บันทึกรหัสใหม่ทับอันเดิมในฐานข้อมูล
|
 |
 |
 |
 |
Date :
2009-11-05 20:42:43 |
By :
adunafah |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าฟอร์มการเปลี่ยนแนะนำให้มี username ด้วยนะค่ะ หรือจะส่งค่ามาจากฟอร์มที่ login เข้ามาก็ได้ค่ะเพื่อง่ายต่อการตรวจสอบค่ะ
Code (VB.NET)
Dim sql As String
Dim cmd As SqlCommand
Dim dr As SqlDataReader
Dim Oldpass As String = ""
sql = "Select pwd As oldpass from _user where ([user]='" & UsernameTextBox.Text & "')"
cmd = New SqlCommand(sql, mySQLConn)
dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows Then
Oldpass = (dr.Item("oldpass"))
End If
dr.Close()
If Oldpass <> PasswordTextBox.Text Then
MessageBox.Show("รหัสผ่านเก่าไม่ถูกต้องค่ะ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
ElseIf newtxtpass.Text <> aginpass.Text Then
MessageBox.Show("กรุณายืนยันรหัสผ่านใหม่ค่ะ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
Else
sql = "Update _user SET pwd='" & newtxtpass.Text & "'"
sql &= " Where (user='" & UsernameTextBox.Text & "')"
Try
With cmd
.CommandType = CommandType.Text
.CommandText = sql
.Connection = mySQLConn
.ExecuteNonQuery()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
End If
MsgBox("เปลี่ยนรหัสผ่านเรียบร้อยแล้วค่ะ")
End Sub
|
 |
 |
 |
 |
Date :
2009-11-06 13:19:43 |
By :
Nicorobin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เตรียม ฐานข้อมูล ชื่อ sldsrv เทเบิล ชื่อ login
หน้า login.aspx มี เท็กบ๊อก2 อัน เลเบล 1อัน ปุ่ม 1อัน
หน้า login.aspx.vb ของ ปุ่ม ตามนี้เลยคับ
Code (VB.NET)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objConn As SqlConnection
Dim dtAdapter As SqlDataAdapter
Dim dt As New DataTable
Dim strConnString As String
strConnString = "server=(local);uid=sa;pwd=50690000;database=sldsrv"
objConn = New SqlConnection(strConnString)
objConn.Open()
Dim strSQL As String
strSQL = "SELECT * FROM login WHERE Username = '" & Me.TextBox1.Text & "'" & _
" AND Password = '" & Me.TextBox2.Text & "' "
dtAdapter = New SqlDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
If dt.Rows.Count <= 0 Then
Me.Label1.Text = "Invalid Username & Password"
Else
Response.Redirect("receive.aspx") '<---นี่คือ เว็ปที่เปิดหลังจาก ใส่รหัสถูก
End If
End Sub
|
 |
 |
 |
 |
Date :
2010-12-25 22:08:09 |
By :
note00001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|