Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 06-23-2005, 10:47 AM   #1 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default ASP.Net

Hi,
I tried a simple program in asp.net. In that program I used a class. Ok. I will post my code here.

Here is my code:

Public Sub DataListOnUpdateHandler(ByVal sender As System.Object, ByVal e As DataListCommandEventArgs)
Dim selekt, varst As String
Dim varmark, varroll As Integer

Dim add As TextBox
add = New TextBox
Dim hp As TextBox
hp = New TextBox
selekt = "select * from mark where serialno=" & varst
Dim updatecon As New OleDbConnection(ConnectionString)
Dim updateadapter As New OleDbDataAdapter(selekt, updatecon)
Dim updatecmdbuilder As New OleDbCommandBuilder(updateadapter)
Dim updatestud As New DataSet
71. add.Text = CType(e.Item.FindControl("textbox1"), TextBox).Text
72. hp.Text = CType(e.Item.FindControl("textbox2"), TextBox).Text
varmark = add.Text
varroll = hp.Text
updateadapter.Fill(updatestud, "mark")
updatestud.Tables("mark").Rows(0)("rollno") = varroll
updatestud.Tables("mark").Rows(0)("mark1") = varmark
updateadapter.Update(updatestud, "mark")
DataList1.EditItemIndex = -1
populate()

End Sub
End Class

Here is Error

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 69: Dim updatecmdbuilder As New OleDbCommandBuilder(updateadapter)
Line 70: Dim updatestud As New DataSet
Line 71: add.Text = CType(e.Item.FindControl("textbox1"), TextBox).Text
Line 72: hp.Text = CType(e.Item.FindControl("textbox2"), TextBox).Text
Line 73: varmark = add.Text


Source File: c:\inetpub\wwwroot\aspdot3\UsingDataList.aspx.vb Line: 71

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
aspdot3.UsingDataList.DataListOnUpdateHandler(Obje ct sender, DataListCommandEventArgs e) in c:\inetpub\wwwroot\aspdot3\UsingDataList.aspx.vb:7 1
System.Web.UI.WebControls.DataList.OnUpdateCommand (DataListCommandEventArgs e) +109
System.Web.UI.WebControls.DataList.OnBubbleEvent(O bject source, EventArgs e) +294
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataListItem.OnBubbleEve nt(Object source, EventArgs e) +100
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +121
System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277


Anyone can help me?

Thanks
Mohan Giri is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On