M
Mike Mahon
I get the error Object reference not set to an instance of an object.
on the Response.Write (ds.Tables("tusers").Rows(0).Item(0)) I know
this is an old way to do it but I can't remember how to write a
message to the output in VS.NET I think I have the ds instantiating.
But I am just screwing up some where stupid. It is a Monday of
course.
Imports System.Data
Imports System.Data.SqlClient
Public Class login
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents txtpwd As System.Web.UI.WebControls.TextBox
Protected WithEvents txtlogin As System.Web.UI.WebControls.TextBox
Protected WithEvents btnlogin As
System.Web.UI.WebControls.LinkButton
Protected WithEvents lblSystemErrorMsg As
System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the
Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Public Shared m_validUser As Boolean
Public Shared Property validuser() As Boolean
Get
Return m_validUser ' Return the value stored in the local
variable.
' Optionally, you can use the syntax One = PropVal to
return
' the property value.
End Get
Set(ByVal Value As Boolean)
m_validUser = Value ' Store the value in a local variable.
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnlogin.Click
validateUser(txtlogin.Text, txtpwd.Text)
Response.Write(validuser)
' If sc.validuser Then
' Response.Redirect("searchresumes.aspx")
' Else
' lblSystemErrorMsg.Text = "Either your user name or
password are incorrect."
' End If
End Sub
Private Function validateUser(ByVal id As String, ByVal pwd As
String)
Dim cn As New
SqlConnection(ConfigurationSettings.AppSettings("cn"))
Dim da As SqlDataAdapter = New SqlDataAdapter
Dim cmd As SqlCommand
Dim ds As DataSet
Dim sout As String
cmd = New SqlCommand("sp_chklogin", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@usr", SqlDbType.VarChar, 20)
cmd.Parameters("@usr").Value = id
cmd.Parameters.Add("@pwd", SqlDbType.VarChar, 20)
cmd.Parameters("@pwd").Value = pwd
'Try
da.SelectCommand = cmd
ds = New DataSet
cn.Open()
da.Fill(ds, "tusers")
'
' If ds.Tables("users").Rows(0).Item(0) = 1 Then
' sout = ds.Tables("users").Rows(0).Item(0)
' Else
Response.Write(ds.Tables("users").Rows(0).Item(0))
' End If
'Catch ex As Exception
'Finally
cn.Close()
'nd Try
End Function
End Class
on the Response.Write (ds.Tables("tusers").Rows(0).Item(0)) I know
this is an old way to do it but I can't remember how to write a
message to the output in VS.NET I think I have the ds instantiating.
But I am just screwing up some where stupid. It is a Monday of
course.
Imports System.Data
Imports System.Data.SqlClient
Public Class login
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
Protected WithEvents txtpwd As System.Web.UI.WebControls.TextBox
Protected WithEvents txtlogin As System.Web.UI.WebControls.TextBox
Protected WithEvents btnlogin As
System.Web.UI.WebControls.LinkButton
Protected WithEvents lblSystemErrorMsg As
System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the
Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Public Shared m_validUser As Boolean
Public Shared Property validuser() As Boolean
Get
Return m_validUser ' Return the value stored in the local
variable.
' Optionally, you can use the syntax One = PropVal to
return
' the property value.
End Get
Set(ByVal Value As Boolean)
m_validUser = Value ' Store the value in a local variable.
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnlogin.Click
validateUser(txtlogin.Text, txtpwd.Text)
Response.Write(validuser)
' If sc.validuser Then
' Response.Redirect("searchresumes.aspx")
' Else
' lblSystemErrorMsg.Text = "Either your user name or
password are incorrect."
' End If
End Sub
Private Function validateUser(ByVal id As String, ByVal pwd As
String)
Dim cn As New
SqlConnection(ConfigurationSettings.AppSettings("cn"))
Dim da As SqlDataAdapter = New SqlDataAdapter
Dim cmd As SqlCommand
Dim ds As DataSet
Dim sout As String
cmd = New SqlCommand("sp_chklogin", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@usr", SqlDbType.VarChar, 20)
cmd.Parameters("@usr").Value = id
cmd.Parameters.Add("@pwd", SqlDbType.VarChar, 20)
cmd.Parameters("@pwd").Value = pwd
'Try
da.SelectCommand = cmd
ds = New DataSet
cn.Open()
da.Fill(ds, "tusers")
'
' If ds.Tables("users").Rows(0).Item(0) = 1 Then
' sout = ds.Tables("users").Rows(0).Item(0)
' Else
Response.Write(ds.Tables("users").Rows(0).Item(0))
' End If
'Catch ex As Exception
'Finally
cn.Close()
'nd Try
End Function
End Class