Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Help on DataSets

Reply
Thread Tools

Help on DataSets

 
 
cagriandac@gmail.com
Guest
Posts: n/a
 
      07-22-2006
Hello,

I am creating an application using asp.net 2.0. But I am stuck
somewhere. I want to get values from a DataSet one by one on every
Page_Load. So I wrote my code in Page_Load but it didnt work, giving a
warning. Here is my code:

Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim ds As DataSet1
Dim test As String
test = ds.Tables("pictureID").Rows(0)("pictureID").ToString
Label1.Text = test
End Sub
And the Warning:

Variable 'ds' is used before it has been assigned a value. A null
reference exception could result at runtime.


How can I handle this warning. Did I wrote the code in wrong place?

I created my DataSet using the menu in Visual Web Developer (Visual
Studio 2005). So I did not write any code for it.

Am I assigning the ds right?
I also assigned it as DataSet1TableAdapter. But it didnt work also. I
am a rookie and any help is appreciated.

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-23-2006
Dim ds As DataSet1 creates a new dataset. It has no connection with the one
you have created. You should be able to use the created one just by its
name. I am not familiar with Visual Web Developer, but usually what you
create is the schema for the dataset. On top of this, you need to load
actual data. And you have to make sure that the dataset gets populated on
every postback. For this you will have to either re-load it on every
postback or save it in a persistent location such as a session variable.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello,
>
> I am creating an application using asp.net 2.0. But I am stuck
> somewhere. I want to get values from a DataSet one by one on every
> Page_Load. So I wrote my code in Page_Load but it didnt work, giving a
> warning. Here is my code:
>
>
Code:
>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
>        Dim ds As DataSet1
>        Dim test As String
>        test = ds.Tables("pictureID").Rows(0)("pictureID").ToString
>        Label1.Text = test
>    End Sub
>
>
> And the Warning:
>
> Variable 'ds' is used before it has been assigned a value. A null
> reference exception could result at runtime.
>
>
> How can I handle this warning. Did I wrote the code in wrong place?
>
> I created my DataSet using the menu in Visual Web Developer (Visual
> Studio 2005). So I did not write any code for it.
>
> Am I assigning the ds right?
> I also assigned it as DataSet1TableAdapter. But it didnt work also. I
> am a rookie and any help is appreciated.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? Francisco Garcia ASP .Net Web Services 3 04-13-2006 05:53 PM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? Francisco Garcia ASP .Net 2 04-13-2006 10:41 AM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? news.microsoft.com ASP .Net Web Services 0 04-12-2006 09:07 AM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? news.microsoft.com ASP .Net 0 04-12-2006 09:07 AM
Help with datasets =?Utf-8?B?RGVhc3Vu?= ASP .Net 1 05-25-2005 03:15 PM



Advertisments