Ask a Question related to Dreamweaver AppDev, Design and Development.
-
JoelTSRoberts #1
object reference error
Can someone please help. I am running locally XP, IIS5. Am trying forms
authentication with no luck in one area. I am using the following script to
check username and password against access2000 db via stored procedures.
<code> <%@ Import Namespace='System.Data' %> <%@ Import
Namespace='System.Data.OleDb' %> <script runat='server'> sub Login(obj as
object, e as eventargs) dim intID as integer = 0 dim Conn as new
OleDbConnection('my conn here') dim objCmd as OleDbCommand = new
OleDbCommand('spValidateUser', Conn) objCmd.CommandType =
CommandType.StoredProcedure dim objReader as OleDbDataReader 'set
parameters for stored procedure dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add('@UserName', OleDbType.BSTR)
objParam.Direction = ParameterDirection.Input objParam.Value =
tbUserName.Text objParam = objCmd.Parameters.Add('@Password',
OleDbType.BSTR) objParam.Direction = ParameterDirection.Input
objParam.Value = tbPassword.Text try
objCmd.Connection.Open() objReader = objCmd.ExecuteReader do
while objReader.Read intID = objReader.GetInt32(0).ToString
loop catch ex as OleDbException lblMessage.Text = ex.Message
finally objReader.Close objCmd.Connection.Close()
end try if intID <> 0 then
FormsAuthentication.SetAuthCookie(intID, false)
Response.redirect('default.aspx') else lblMessage.Text = '<font
color=red>Sorry, invalid username or password!</font><p>' end if end
sub </script> </code> I get the following error (line 42 is the error) in
debug mode: Object reference not set to an instance of an object. Exception
Details: System.NullReferenceException: Object reference not set to an instance
of an object. Source Error: Line 40: lblMessage.Text = ex.Message Line 41:
finally Line 42: objReader.Close Line 43: objCmd.Connection.Close() Line 44:
end try Can someone please help before I rip my hair out! Cheers
JoelTSRoberts Guest
-
Object Reference Error. Pls Help!
Hi, I'm having a major issue with one of the custom contols I've created. Basically, it consists of a dropdown, button and some textboxes for the... -
Mysterious Error: Object reference not set to an instance of an object
Hi There! I'm having a mysterious error right after I login using Forms Authentication in my ASP.NET app. Below is the error... Exception... -
Error msg: Bad foreign object reference
I am using Acrobat Std v. 6.0.1 11/3/2003 to create PDF files from MS Word files or web pages and email them to others over the Internet. Recipients... -
HELP! Error Loading ASPX : Object Reference not set to an instance object
Hello, When i run my aspx i get this weird error: System.NullReferenceException: Object reference not set to an instance of an object. at... -
Object reference not set to an instance of an object. .......... Error .... Please Help
Hi, I am facing a problem, and i don't know why the error is being generated. I am updating a datagrid with an XML file. My code is ... -
Paul Whitham TMM #2
Re: object reference error
The error normally means that you are calling a web control (ie a text box)
in the code that does not exist on the page. Check that the names of the
fields are all correct and that they are webcontrols (denoted by a asp:) in
front of them and that they have a runat=server attribute.
--
Regards
Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
[url]www.valleybiz.net[/url]
Team Macromedia Volunteer for Ultradev/Dreamweaver MX
[url]www.macromedia.com/support/forums/team_macromedia[/url]
"JoelTSRoberts" <webforumsuser@macromedia.com> wrote in message
news:d17q67$rk3$1@forums.macromedia.com...to> Can someone please help. I am running locally XP, IIS5. Am trying forms
> authentication with no luck in one area. I am using the following scriptas> check username and password against access2000 db via stored procedures.
> <code> <%@ Import Namespace='System.Data' %> <%@ Import
> Namespace='System.Data.OleDb' %> <script runat='server'> sub Login(objnew> object, e as eventargs) dim intID as integer = 0 dim Conn as'set> OleDbConnection('my conn here') dim objCmd as OleDbCommand = new
> OleDbCommand('spValidateUser', Conn) objCmd.CommandType =
> CommandType.StoredProcedure dim objReader as OleDbDataReaderdo> parameters for stored procedure dim objParam as OleDbParameter
> objParam = objCmd.Parameters.Add('@UserName', OleDbType.BSTR)
> objParam.Direction = ParameterDirection.Input objParam.Value =
> tbUserName.Text objParam = objCmd.Parameters.Add('@Password',
> OleDbType.BSTR) objParam.Direction = ParameterDirection.Input
> objParam.Value = tbPassword.Text try
> objCmd.Connection.Open() objReader = objCmd.ExecuteReaderex.Message> while objReader.Read intID = objReader.GetInt32(0).ToString
> loop catch ex as OleDbException lblMessage.Text ='<font> finally objReader.Close objCmd.Connection.Close()
> end try if intID <> 0 then
> FormsAuthentication.SetAuthCookie(intID, false)
> Response.redirect('default.aspx') else lblMessage.Text =end> color=red>Sorry, invalid username or password!</font><p>' end ifin> sub </script> </code> I get the following error (line 42 is the error)Exception> debug mode: Object reference not set to an instance of an object.instance> Details: System.NullReferenceException: Object reference not set to anLine 41:> of an object. Source Error: Line 40: lblMessage.Text = ex.MessageLine 44:> finally Line 42: objReader.Close Line 43: objCmd.Connection.Close()> end try Can someone please help before I rip my hair out! Cheers
>
Paul Whitham TMM Guest



Reply With Quote

