what is the reason for this error and how can we resolve this
it will come at the time of login page Below is my code....
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Data.OleDb.OleDbConnection
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Web.ParserError
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlDbType
Imports System.Web.UI.Page
Imports System.DirectoryServices
Imports System.DirectoryServices.ResultPropertyCollection
Partial Class Login
Inherits System.Web.UI.Page
Public cn As SqlConnection
Dim con As OleDbConnection
Dim RGENCN As OleDbConnection
Dim LoginStatus As Boolean
Public objConnection As New SqlConnection
Public objCommand As New SqlCommand
Public strSQL As String
Public strRatingimg As Integer
Public iRandomRecipe As Integer
Public strRName As String
Public strCName As String
Public Event pageIndexChanging As GridViewPageEventHandler
Dim instance As GridView
Dim handler As GridViewPageEventHandler
Private priceTotal As Double = 0.0
Private Totaldiffrenece As Double = 0.0
Private TotalActual As Double = 0.0
Private Amounts As Double = 0.0
Dim i As Integer
Dim CookieName As String
Dim aCookie As HttpCookie
Dim k As Integer
Public gblUserName As String
Public gblEmail As String
Public gblPhone As String
Public gblCustomerLogin As Boolean
Public gblEmployeeLogin As Boolean
Public Qstr As String
Function fixquotes(ByVal inputstring As String) As String
inputstring = Replace(inputstring, "'", "")
inputstring = Replace(inputstring, "%", "")
inputstring = Replace(inputstring, "<", "")
inputstring = Replace(inputstring, ">", "")
inputstring = Replace(inputstring, "+", "")
inputstring = Replace(inputstring, "/", "")
Return inputstring
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Response.Headers.Remove("Cache-Control")
'Response.Headers.Remove("Content-Length")
'Response.Headers.Remove("Content-Type")
'Response.Headers.Remove("Server")
strUserLogConnection = ConfigurationManager.ConnectionStrings("SPMGLOBAL_STG").ConnectionString
cn = New SqlConnection(ConfigurationManager.ConnectionStrings("NONProviderSPMGLOBAL_STG").ConnectionString)
con = New OleDbConnection(strUserLogConnection)
If con.State = 1 Then con.Close()
con.Open()
TestWebMsgApp.WebMsgBox.DatabaseConnectionTNT()
TestWebMsgApp.WebMsgBox.DatabaseConnectionTKLCINV()
RGENCN = TestWebMsgApp.WebMsgBox.getMyConnectionTNT
txtuser.Focus()
If Page.IsPostBack = False Then
' GetLocation()
End If
End Sub
Private Sub GetLocation()
'Try
' Using con = New OleDbConnection(strUserLogConnection)
' Using cmd As New OleDbCommand("SELECT DeptID, DeptCode, DeptName FROM dbo.DeptMaster Where DeptID IN (7,8,9,10)")
' cmd.CommandType = CommandType.Text
' cmd.Connection = con
' Using sda As New OleDbDataAdapter(cmd)
' Dim ds As New DataSet()
' sda.Fill(ds)
' cmbDepot.DataSource = ds.Tables(0)
' cmbDepot.DataTextField = "DeptName"
' cmbDepot.DataValueField = "DeptName"
' cmbDepot.DataBind()
' End Using
' End Using
' End Using
' cmbDepot.Items.Insert(0, New ListItem("--Select Customer--", "0"))
'Catch ex As Exception
' con.Close()
' con = Nothing
'Finally
' If con.State = 1 Then con.Close()
' con = Nothing
'End Try
Try
con.Open()
cmbDepot.Items.Clear()
cmbDepot.Items.Add("Select Location")
Qstr = " SELECT DeptID, DeptCode, DeptName" & _
" FROM dbo.DeptMaster Where DeptID IN (7,8,9,10)"
Dim Ird As OleDbDataReader
Dim Icmd As New OleDbCommand(Qstr, con)
Ird = Icmd.ExecuteReader
While Ird.Read
cmbDepot.Items.Add(Ird("DeptName"))
End While
con.Close()
Ird.Close()
Catch ex As Exception
End Try
End Sub
Private Sub SubmitWronglogin()
Dim strClientIP As String
strClientIP = Request.UserHostAddress()
lblIPGot.Text = "This computer is using IP address : " & strClientIP.ToString
lblIPGot1.Text = "This is personal web hosting so do not try to misuse."
If txtUserID.Text = "" Then txtUserID.Text = 0
Dim Qstr As String = "Insert into UserLog (UserID, UserName,LoginDate, System,Application,Hack) values (" & fixquotes(txtUserID.Text) & ",'" & txtuser.Text & "',getdate(),'" & strClientIP.ToString & "','" & "GLOBAL SPM" & "','" & "H" & "')"
Dim Ird As Data.OleDb.OleDbDataReader
Dim Icmd As New Data.OleDb.OleDbCommand(Qstr, con)
Ird = Icmd.ExecuteScalar
Exit Sub
End Sub
Sub loginuser(ByVal Sender As Object, ByVal e As EventArgs) Handles Button1.Click
If txtuser.Text = "" Then
lblerror.Text = "Input Correct User Name"
lblerror.Visible = True
txtuser.Focus()
Exit Sub
Else
lblerror.Visible = False
End If
If txtpass.Text = "" Then
lblerror.Text = "Input Correct User Name Password "
lblerror.Visible = True
txtpass.Focus()
Exit Sub
Else
lblerror.Visible = False
End If
'Dim isauthenticated As Boolean = AuthenticateUser()
'If isauthenticated Then
Try
cn.Open()
Dim str As String = " select UserID, UserName, UPassword, FullName, DeptID, EmailID, isActive, DeptAbbr, IsAdmin,Customer,GLBL" & _
" from SPMGLOBAL_PRD.dbo.RMSUsers where UPassword=CONVERT(varbinary,'" & Jabil_CRM.CRM.TDecrypt(fixquotes(Trim(txtpass.Text))) & "') and UserName='" & fixquotes(Trim(txtuser.Text)) & "' and isActive=1"
Dim rd As SqlDataReader
Dim rcmd As New SqlCommand(str, cn)
rd = rcmd.ExecuteReader
If rd.Read Then
Dim Prog As String
Dim userID As String = rd.GetValue(0)
Dim UserName As String = rd.GetString(1)
Dim Email As String = Trim(rd.GetString(5))
Dim FullName As String = Trim(rd.GetString(3))
Dim DeptID As String = Trim(rd.GetValue(4))
Session("GLBL") = Trim(rd("GLBL"))
Session("DeptID") = DeptID.ToString
Session("FullName") = FullName.ToString
Session("UserID") = userID.ToString
Session("UserName") = UserName.ToString
Session("EmailID") = Email.ToString
Session("Login") = rd.GetValue(7)
Session("Admin") = rd.GetValue(7)
Session("DeptAbbr") = Trim(rd("DeptAbbr"))
Session("IsAdmin") = Trim(rd("IsAdmin"))
Session("Customer") = Trim(rd("Customer"))
Dim Cusomer As String = Trim(rd("Customer"))
LoginStatus = True
Prog = Trim(rd.GetString(7))
Session("Prog") = Prog.ToString
Session("Qstr") = ""
Dim strClientIP As String
strClientIP = Request.UserHostAddress()
Session("IP") = strClientIP
Session("Time") = Date.Now.ToString("HH:mm:ss")
Qstr = "Insert into UserLog (UserID, LoginDate, System,UserName,Application) values (" & _
userID.ToString & ",getdate(),'" & strClientIP.ToString & "','" & fixquotes(UserName.ToString) & "','" & "GLOBAL SPM" & "')"
Dim Ird As OleDbDataReader
Dim Icmd As New OleDbCommand(Qstr, con)
Ird = Icmd.ExecuteScalar
If Not Session("UserName") = "" Then
lblUserName.Visible = False
lblPassword.Visible = False
txtuser.Visible = False
txtpass.Visible = False
Button1.Visible = False
lblmessege.Visible = False
Else
lblUserName.Visible = True
lblPassword.Visible = True
txtuser.Visible = True
txtpass.Visible = True
Button1.Visible = True
lblmessege.Visible = True
End If
Try
Dim gblFromDate As String = "01-Apr-" & Date.Now.Year
Dim gblToDate As String = "31-Mar-" & Date.Now.Year + 1 & " 23:23:59"
Qstr = "Select StartDate, EndDate from FinYears where StartDate>='" & gblFromDate & "' and EndDate<='" & gblToDate & "'"
Dim CIrd As OleDbDataReader
Dim CIcmd As New OleDbCommand(Qstr, con)
CIrd = CIcmd.ExecuteReader
If CIrd.Read Then
Session("gblFinStartDate") = CIrd.GetDateTime(0).ToString("dd-MMM-yyyy")
Session("gblFinEndDate") = CIrd.GetDateTime(1).ToString("dd-MMM-yyyy")
Else
Session("gblFinStartDate") = gblFromDate
Session("gblFinEndDate") = gblToDate
End If
Catch ex As Exception
TestWebMsgApp.WebMsgBox.Show(ex.Message)
Exit Sub
End Try
Try
Qstr = "SELECT UserID, Permission FROM SPMGLOBAL_PRD.dbo.CICPermission Where UserID=" & Session("UserID") & ""
Dim CIrd As OleDbDataReader
Dim CIcmd As New OleDbCommand(Qstr, con)
CIrd = CIcmd.ExecuteReader
If CIrd.Read Then
Session("Permission") = CIrd("Permission")
Else
Session("Permission") = "IN (0," & Session("DeptID") & ")"
End If
Catch ex As Exception
TestWebMsgApp.WebMsgBox.Show(ex.Message)
Exit Sub
End Try
Try
cmbDepot.Items.Clear()
cmbDepot.Items.Add("Select Location")
con.Open()
Qstr = " SELECT DeptID, DeptCode, DeptName" & _
" FROM dbo.DeptMaster Where DeptID " & Session("Permission") & ""
Dim LIrd As OleDbDataReader
Dim LIcmd As New OleDbCommand(Qstr, con)
LIrd = LIcmd.ExecuteReader
While LIrd.Read
cmbDepot.Items.Add(LIrd("DeptName"))
End While
con.Close()
LIrd.Close()
MPEQuote.Show()
Catch ex As Exception
End Try
Else
'Dim Qstr As String = " Update Users set isActive=0 where UserName='" & txtuser.Text & "'"
'Dim Ird As OleDbDataReader
'Dim Icmd As New OleDbCommand(Qstr, con)
'Ird = Icmd.ExecuteScalar
SubmitWronglogin()
Session.RemoveAll()
lblmessege.Text = "Account has been Locked "
Exit Sub
End If
Catch ex As SqlException
Finally
cn.Close()
' cn = Nothing
End Try
lblmessege.Text = "YOU HAVE BEEN AUTHENTICATED RMS "
'Else
'lblmessege.Text = "YOU HAVE NOT BEEN AUTHENTICATED IN AD "
'SubmitWronglogin()
'End If
End Sub
Protected Sub cmdSpareQuote_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSpareQuote.Click
Try
Qstr = "SELECT DeptID, TAX, DeptName, DeptCode,REGION_NAME FROM dbo.DeptMaster Where DeptName='" & cmbDepot.Text & "'"
Dim DIrd As OleDbDataReader
Dim DIcmd As New OleDbCommand(Qstr, con)
DIrd = DIcmd.ExecuteReader
If DIrd.Read Then
Session("DeptID") = Trim(DIrd("DeptID"))
Session("DeptCode") = Trim(DIrd("DeptCode"))
Session("DeptName") = Trim(DIrd("DeptName"))
Session("TAX") = Trim(DIrd("TAX"))
Session("REGION_NAME") = Trim(DIrd("REGION_NAME"))
lblerror.Visible = False
lblerror.Text = ""
lblmessege.Visible = False
lblmessege.Text = ""
Try
Qstr = " SELECT UserName, PWD" & _
" FROM SPMGLOBAL_PRD.dbo.JBLADUsers Where UserName='" & Session("UserName") & "'"
Dim GDIrd As OleDbDataReader
Dim GDIcmd As New OleDbCommand(Qstr, con)
GDIrd = GDIcmd.ExecuteReader
If Not GDIrd.Read Then
Qstr = "Insert into SPMGLOBAL_PRD.dbo.JBLADUsers (UserName, PWD) values ('" & _
Session("UserName") & "','" & Session("PWD") & "')"
Dim PDIrd As OleDbDataReader
Dim PDIcmd As New OleDbCommand(Qstr, con)
PDIrd = PDIcmd.ExecuteScalar
End If
Catch ex As Exception
lblerror.Visible = True
lblerror.Text = "Select Correct Global AD Not Found"
MPEQuote.Show()
Exit Sub
End Try
Try
Session("indeptname") = "in ("
Qstr = " SELECT DeptID, DeptCode, DeptName,DeptAbbr" & _
" FROM dbo.DeptMaster Where DeptID " & Session("Permission") & ""
Dim LIrd As OleDbDataReader
Dim GDIcmd As New OleDbCommand(Qstr, con)
LIrd = GDIcmd.ExecuteReader
While LIrd.Read
If Session("indeptname") = "in (" Then
Session("indeptname") = Session("indeptname") & "'" & Trim(LIrd("DeptName")) & "'"
Else
Session("indeptname") = Session("indeptname") & ",'" & Trim(LIrd("DeptName")) & "'"
End If
End While
Session("indeptname") = Session("indeptname") & ")"
Catch ex As Exception
lblerror.Visible = True
lblerror.Text = "Select Correct Global AD Not Found"
MPEQuote.Show()
Exit Sub
End Try
'Session("Customer") = "MAPU"
If Trim(Session("Customer")) = "TLMR" Then
Dim Customer As String = 1
Dim UserSession As String = Session.SessionID
ResponseHelper.Redirect("RelianceProjectHome.aspx?Customer=" & Customer.ToString & "&UserSession=" & UserSession.ToString & "&Page=" & UserSession.ToString & "", "_New", "menubar=0,width=1100,height=650,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no'")
ElseIf Trim(Session("Customer")) = "HP" Then
Dim Customer As String = 1
Dim UserSession As String = Session.SessionID
ResponseHelper.Redirect("http://telmarindia.telmarnt.com?Customer=" & Customer.ToString & "&UserSession=" & UserSession.ToString & "&Page=" & UserSession.ToString & "", "_New", "menubar=0,width=1100,height=650,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no'")
ElseIf Trim(Session("Customer")) = "MAPU" Then
Dim Customer As String = 1
Dim UserSession As String = Session.SessionID
ResponseHelper.Redirect("MAIPUHomePage.aspx?Customer=" & Customer.ToString & "&UserSession=" & UserSession.ToString & "&Page=" & UserSession.ToString & "", "_New", "menubar=0,width=1100,height=650,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no'")
ElseIf Trim(Session("Customer")) = "INDS" Then
Dim Customer As String = 1
Dim UserSession As String = Session.SessionID
ResponseHelper.Redirect("NDSHomePage.aspx?Customer=" & Customer.ToString & "&UserSession=" & UserSession.ToString & "&Page=" & UserSession.ToString & "", "_New", "menubar=0,width=1100,height=650,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no'")
ElseIf Trim(Session("Customer")) = "HPNT" Then
Dim Customer As String = 1
Dim UserSession As String = Session.SessionID
ResponseHelper.Redirect("HPRHomePage.aspx?Customer=" & Customer.ToString & "&UserSession=" & UserSession.ToString & "&Page=" & UserSession.ToString & "", "_New", "menubar=0,width=1100,height=650,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no'")
ElseIf Trim(Session("Customer")) = "UTSI" Then
Dim Customer As String = 1
Dim UserSession As String = Session.SessionID
ResponseHelper.Redirect("UTSICHomePage.aspx?Customer=" & Customer.ToString & "&UserSession=" & UserSession.ToString & "&Page=" & UserSession.ToString & "", "_New", "menubar=0,width=1100,height=650,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no'")
ElseIf Trim(Session("Customer")) = "BILI" Then
Dim Customer As String = 1
Dim UserSession As String = Session.SessionID
ResponseHelper.Redirect("NDSHomePageC.aspx?Customer=" & Customer.ToString & "&UserSession=" & UserSession.ToString & "&Page=" & UserSession.ToString & "", "_New", "menubar=0,width=1100,height=650,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no'")
End If
Else
lblerror.Visible = True
lblerror.Text = "Select Correct CIC Location"
MPEQuote.Show()
Exit Sub
End If
Catch ex As Exception
TestWebMsgApp.WebMsgBox.Show(ex.Message)
Exit Sub
End Try
End Sub
Protected Sub cmdQuoteExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdQuoteExit.Click
Session("DeptID") = ""
Session("FullName") = ""
Session("UserID") = ""
Session("UserName") = ""
Session("EmailID") = ""
Session("Login") = ""
Session("Admin") = ""
Session("DeptAbbr") = ""
Session("IP") = ""
lblUserName.Visible = True
lblPassword.Visible = True
txtuser.Visible = True
txtpass.Visible = True
Button1.Visible = True
lblmessege.Visible = True
End Sub
End Class
What I have tried:
its sql related problem of code problem