HOME > .NET Framework > Forum > รอบกวน พี่ ๆ หน่อยนะครับ "ขึ้น Incorrect syntax near '='. ตรง Dim CurrentName As String = CStr(com.ExecuteScalar)" ครับ
รอบกวน พี่ ๆ หน่อยนะครับ "ขึ้น Incorrect syntax near '='. ตรง Dim CurrentName As String = CStr(com.ExecuteScalar)" ครับ
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim username As String
Dim pwd As String
'-------------------------------------
username = Login1.UserName
pwd = Login1.Password
'-------------------------------------
Dim StrConn As String
StrConn = WebConfigurationManager.ConnectionStrings("Database").ConnectionString
Dim Conn As New SqlConnection(StrConn)
Conn.Open()
'-------------------------------------
Dim sqlUserName As String
sqlUserName = "SELECT Username.Password From member"
sqlUserName &= "WHERE (Username ="" & username & "")"
sqlUserName &= "AND (Password ="" & pwd & "" )"
Dim com As New SqlCommand(sqlUserName, Conn)
'-------------------------------------
Dim CurrentName As String = CStr(com.ExecuteScalar)
If CurrentName <> "" Then
e.Authenticated = True
Session("UserAuthentication") = username
Session.Timeout = 1
Response.Redirect("admin/AdministratorPage.aspx")
Else
e.Authenticated = False
Session("UserAuthentication") = ""
End If
End Sub
End Class
Dim sqlUserName As String
sqlUserName = " SELECT Username.Password From member "
sqlUserName &= " WHERE (Username ="" & username & "") "
sqlUserName &= " AND (Password ="" & pwd & "" ) "
Dim com As New SqlCommand(sqlUserName, Conn)