Re: c:\inetpub\wwwroot\PZIssueTracker\User.aspx.vb(165): 'System.Data.DataRow.Protec by anonymous
anonymous
Mon Feb 21 12:29:46 CST 2005
thank you for all of your help on this. i was informed
that VB.NET creates an adapter object for use with the sql
commands. also, i did not instantiate a NEW DsUser. after
reading it over a few times, i realized my own folly. the
only adjustment was to add the keyword New to my
declaration.
sincerely,
trisha
>-----Original Message-----
>An instance of dsUser or dsUser.User doesn't exist....
>
>--
>Miha Markic [MVP C#] - RightHand .NET consulting &
development
>www.rthand.com
>SLODUG - Slovene Developer Users Group www.codezone-
si.info
>
><anonymous@discussions.microsoft.com> wrote in message
>news:08d001c5181a$76363ed0$a501280a@phx.gbl...
>> good morning again, i've captured my error below. i've
>> also re-written my code so it is more adapted to my User
>> table in the database. I'm not sure why it gives me this
>> error, but i've checked the data adapter, made sure the
>> data set was filled with the Fill(), and i'm still
getting
>> the same error at the same row 182:
>>
>> 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 180: 'create a new row for the dataset
>> Line 181: Dim rowNew As DsUser.UserRow
>> Line 182: rowNew = dsUser.User.NewUserRow()
>> Line 183: 'add data to the row
>> Line 184: rowNew("userID") = txtUserID.Text
>>
>>
>> Source File:
>> c:\inetpub\wwwroot\PZIssueTracker\User.aspx.vb Line:
>> 182
>>
>> Stack Trace:
>>
>>
>> [NullReferenceException: Object reference not set to an
>> instance of an object.]
>> PZIssueTracker.User.butAddUser_Click(Object sender,
>> EventArgs e) in
>> c:\inetpub\wwwroot\PZIssueTracker\User.aspx.vb:182
>> System.Web.UI.WebControls.Button.OnClick(EventArgs e)
>>
>>
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEve
>> ntHandler.RaisePostBackEvent(String eventArgument)
>> System.Web.UI.Page.RaisePostBackEvent
>> (IPostBackEventHandler sourceControl, String
eventArgument)
>> System.Web.UI.Page.RaisePostBackEvent
>> (NameValueCollection postData)
>> System.Web.UI.Page.ProcessRequestMain()
>>
>>
>> i apologize if i'm not efficient in explaining my error;
>> i'm just trying to learn VB.NET and ADO.NET at the same
>> time.
>>
>> sincerely,
>> trisha
>>
>>>-----Original Message-----
>>>In which row happens the error (when you are nto using
>> new)?
>>>
>>>--
>>>Miha Markic [MVP C#] - RightHand .NET consulting &
>> development
>>>www.rthand.com
>>>SLODUG - Slovene Developer Users Group www.codezone-
>> si.info
>>>
>>><anonymous@discussions.microsoft.com> wrote in message
>>>news:067801c515f1$5edb9e40$a501280a@phx.gbl...
>>>> when i do not include the New, i run into the browser
>>>> error that states "object reference not set to
instance
>> of
>>>> an object" and i cannot get past it.
>>>>
>>>> again, many thanks.
>>>>>-----Original Message-----
>>>>>Dim rowNew As DataRow
>>>>>rowNew = dsUser.Tables("User").NewRow()
>>>>>
>>>>>This is the correct way. What's wrong with this
>> approach?
>>>>>
>>>>>--
>>>>>Miha Markic [MVP C#] - RightHand .NET consulting &
>>>> development
>>>>>www.rthand.com
>>>>>SLODUG - Slovene Developer Users Group www.codezone-
>>>> si.info
>>>>>
>>>>><anonymous@discussions.microsoft.com> wrote in message
>>>>>news:000901c515ee$f82ee5f0$a401280a@phx.gbl...
>>>>>>I get this error if i instantiate the rowNew as a New
>>>>>> DataRow, but if I don't use it, on the browser I get
>> an
>>>>>> object not instantiated error.
>>>>>>
>>>>>> thanks
>>>>>> 'System.Data.DataRow.Protected Sub New(builder As
>>>>>> System.Data.DataRowBuilder)' is not accessible in
this
>>>>>> context because it is 'Protected'.
>>>>>>
>>>>>>>-----Original Message-----
>>>>>>>What is the error?
>>>>>>>
>>>>>>>--
>>>>>>>Miha Markic [MVP C#] - RightHand .NET consulting &
>>>>>> development
>>>>>>>www.rthand.com
>>>>>>>SLODUG - Slovene Developer Users Group www.codezone-
>>>>>> si.info
>>>>>>>
>>>>>>>"new2.NET" <anonymous@discussions.microsoft.com>
wrote
>>>> in
>>>>>> message
>>>>>>>news:062f01c515ed$370eb3b0$a501280a@phx.gbl...
>>>>>>>> Hi. I'm new to databinding and all that ADO.NET
>>>> stuff. I
>>>>>>>> keep getting an object reference not set to an
>>>> instance
>>>>>> of
>>>>>>>> an object error. And if I try to create a new
>> DataRow
>>>>>> with
>>>>>>>> this code, I get the compiler error in the subject
>>>>>> line. I
>>>>>>>> don't know how to handle this or how to change my
>> code
>>>>>> to
>>>>>>>> make it work. Below is my code which I cannot get
to
>>>>>> work.
>>>>>>>>
>>>>>>>> 'create a new row for the dataset
>>>>>>>> Dim rowNew As DataRow
>>>>>>>> rowNew = dsUser.Tables("User").NewRow()
>>>>>>>> 'add data to the row
>>>>>>>> rowNew("userID") = txtUserID.Text
>>>>>>>> rowNew("userfName") = txtFirstName.Text
>>>>>>>> rowNew("userlname") = txtLastName.Text
>>>>>>>> rowNew("userDeptName") = txtDeptNumber.Text
>>>>>>>> rowNew("userEmail") = txtEmailAdd.Text
>>>>>>>> rowNew("userSupervisorID") =
txtSuperID.Text
>>>>>>>> 'add the row to the data set
>>>>>>>> dsUser.Tables("User").Rows.Add(rowNew)
>>>>>>>> 'update database
>>>>>>>> adptUser.Update(dsUser, "User")
>>>>>>>>
>>>>>>>> 'rebind each text box to a different column
>> in
>>>>>> the
>>>>>>>> ** code removed
>>>>>>>> dataset
>>>>>>>>
>>>>>>>> Try
>>>>>>>> 'modify the database
>>>>>>>> adptUser.Update(dsUser)
>>>>>>>> ** code removed
>>>>>>>>
>>>>>>>> Thanks in advance.
>>>>>>>> new2.NET
>>>>>>>
>>>>>>>
>>>>>>>.
>>>>>>>
>>>>>
>>>>>
>>>>>.
>>>>>
>>>
>>>
>>>.
>>>
>
>
>.
>