|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help on DataSetsI 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 [/code] 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 so any help is appreciated. DotNetDaddy,
If you want to get individual results focus you than on the datatable. The dataset is just a very extended wrapper arround that (and around the relations to that). Your error is because "ds" in your code is only a placeholder address for an object which is not filled yet (Is Nothing). You have to set it to, to the actual object as is created. (Or use that direct) Cor Show quoteHide quote "Dot Net Daddy" <cagrian***@gmail.com> schreef in bericht news:1153598571.054394.64430@m73g2000cwd.googlegroups.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 > [/code] > > 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 so any help is appreciated. > You need to make ds = New DataSet1, then populate the dataset with data.
T Dot Net Daddy wrote: Show quoteHide quote >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 >[/code] > >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 so any help is appreciated. > > >
Can anyone help with proper use of operator CType in VB.net?
where to store sound file Difference between Cint and Convert.ToInt32 ? Data Source error... help!? Getting msgbox to appear on top of splashscreen VB.net 2005 OOP Confused Vb Win app crashes on start How can I to pass an array to a DLL function? Can you not do this? PrintPreview control does not print |
|||||||||||||||||||||||