|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Object reference not set to an instance of an object.help.... here's my code in forgot.aspx.vb ------------------------------------------------------------------ Sub lookup_click(ByVal s As Object, ByVal e As EventArgs) Dim email As String = Request.Form("email") Dim p As New PartyHouse Dim ds As DataSet ds = p.getDetail("*", "member", "memail", email) If ds Is Nothing Then msg.Text = "<font color=red>Sorry, there is no user with email address <b>" & _ email & "</b> found.<br>Click <a href='register2.aspx'>here</a> to register.</font>" Else Dim msgMail As New MailMessage msgMail.To = email msgMail.From = "ad***@partyhouse.com" msgMail.Subject = "Password look up - PartyHouse.com" With ds.Tables("member").Rows(0) msgMail.BodyFormat = MailFormat.Html msgMail.Body = "<html><body><a href='https://localhost/partyhouse/'><img src='img/logomask.gif'></a>" & _ "<p>Dear " & .Item("title") & " " & .Item("fname") & " " & .Item("lname") & ",</p>" & _ "<p>Your password is <b>" & .Item("mpassword") & "</b>. "<p>Please keep this information for future use.</p>" &" & _ _ "<p><br><br> Administrator @ <a href='https://localhost/partyhouse/'>PartyHouse.com</a></p>" & _ "</body></html>" End With SmtpMail.Send(msgMail) Response.Redirect("lookedup.htm") End If End Sub ----------------------------------------------------------------- Here's my code for Partyhouse class: ----------------------------------------------------------------- Public Function getDetail(ByVal thing As String, ByVal table As String, ByVal cond1 As String, ByVal val1 As String) As DataSet oCon = New OleDbConnection( _ "Provider=sqloledb;" & _ "Data Source=ts04.comp.nus.edu.sg,1433;" & _ "Initial Catalog=cs3266_00;" & _ "User Id=lydiasun;" & _ "Password=u0201098") Dim query As String query = "select " & thing & " from " & table & " where " & cond1 & "='" & val1 & "'" Dim mycommand As New OleDbCommand(query, oCon) oCon.Open() Dim dr As OleDbDataReader dr = mycommand.ExecuteReader(CommandBehavior.CloseConnection) Dim ds As DataSet If dr.HasRows = True Then ds = ConvertDataReaderToDataSet(dr) 'this function is to convert data reader to dataset. 'it's correct i've tried it out. Else ds = Nothing End If oCon.Close() Return ds End Function ----------------------------------------------------------------------- can anyone help me please?? thanks.. Hi,
First off not the smartest thing to post your database username, password, and server. Dont understand why you are converting a datareader to a dataset why not just read in the dataset to begin with. Add Imports system.data.sqlclient to the top of the code file. I dont think your convertdatareadertodataset made a datatable with the name of member. I think that is the object not set to reference of an object error you are getting. Public Function getDetail(ByVal thing As String, ByVal table As String, ByVal cond1 As String, ByVal val1 As String) As DataSet oCon = New SQLConnection( _ "Data Source=ts04.comp.nus.edu.sg,1433;" & _ "Initial Catalog=cs3266_00;" & _ "User Id=lydiasun;" & _ "Password=u0201098") Dim query As String query = "select " & thing & " from " & table & " where " & cond1 & "='" & val1 & "'" Dim mycommand As New sqlCommand(query, oCon) oCon.Open() Dim da As new sqlDataReader(mycommand) Dim ds As DataSet da.Fill(ds, "member") Return ds End Function Change your this in the lookup_click procedure If ds Is Nothing Then to If ds.Tables("member").Rows.Count < 1 Then Hope this helps. Ken ----------------------- Show quoteHide quote "sista via DotNetMonster.com" wrote: > Wonder why I always got tis error? :( > help.... > > here's my code in forgot.aspx.vb > ------------------------------------------------------------------ > Sub lookup_click(ByVal s As Object, ByVal e As EventArgs) > Dim email As String = Request.Form("email") > Dim p As New PartyHouse > Dim ds As DataSet > ds = p.getDetail("*", "member", "memail", email) > > If ds Is Nothing Then > msg.Text = "<font color=red>Sorry, there is no user with email > address <b>" & _ > email & "</b> found.<br>Click <a href='register2.aspx'>here</a> > to register.</font>" > Else > Dim msgMail As New MailMessage > msgMail.To = email > msgMail.From = "ad***@partyhouse.com" > msgMail.Subject = "Password look up - PartyHouse.com" > > With ds.Tables("member").Rows(0) > msgMail.BodyFormat = MailFormat.Html > msgMail.Body = "<html><body><a > href='https://localhost/partyhouse/'><img src='img/logomask.gif'></a>" & _ > "<p>Dear " & .Item("title") & " " & .Item("fname") & " > " & .Item("lname") & ",</p>" & _ > "<p>Your password is <b>" & .Item("mpassword") & "</b>. > " & _ > "<p>Please keep this information for future use.</p>" & > _ > "<p><br><br> Administrator @ <a > href='https://localhost/partyhouse/'>PartyHouse.com</a></p>" & _ > "</body></html>" > End With > SmtpMail.Send(msgMail) > > Response.Redirect("lookedup.htm") > End If > End Sub > ----------------------------------------------------------------- > > > Here's my code for Partyhouse class: > ----------------------------------------------------------------- > Public Function getDetail(ByVal thing As String, ByVal table As String, > ByVal cond1 As String, ByVal val1 As String) As DataSet > oCon = New OleDbConnection( _ > "Provider=sqloledb;" & _ > "Data Source=ts04.comp.nus.edu.sg,1433;" & _ > "Initial Catalog=cs3266_00;" & _ > "User Id=lydiasun;" & _ > "Password=u0201098") > Dim query As String > query = "select " & thing & " from " & table & " where " & cond1 & > "='" & val1 & "'" > Dim mycommand As New OleDbCommand(query, oCon) > > oCon.Open() > Dim dr As OleDbDataReader > dr = mycommand.ExecuteReader(CommandBehavior.CloseConnection) > > Dim ds As DataSet > If dr.HasRows = True Then > ds = ConvertDataReaderToDataSet(dr) > 'this function is to convert data reader to dataset. > 'it's correct i've tried it out. > Else > ds = Nothing > End If > oCon.Close() > Return ds > End Function > ----------------------------------------------------------------------- > > can anyone help me please?? > thanks.. > > -- > Message posted via http://www.dotnetmonster.com >
Loopy over loops
REALbasic 5.5 free to VB6 Users Untili March 31 2005 spice the boring default winforms treeview appearance up a bit... Help with SendMessage API calls From VB.NET to Delphi7 convert. looking for CPU-specific developer's benchmarking e.Cancel = True in MDI Child Closing event Tabcontrol tabpagebutton orientation List View question inheritance and shared |
|||||||||||||||||||||||