0

I am using visual studio vb asp.net, i am trying to use dataset.xsd. but i am getting error. It is showing error , that ABC variable is used before it has been assigned a value a null reference exception could result at the runtime

in my program i have loginDataSet.xsd > uloginDS

this is the coding

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Dim uloginAdapter1 As New loginDataSetTableAdapters.uLoginDSTableAdapter
    Dim ds1 As loginDataSet.uLoginDSDataTable
    Dim abc As loginDataSet.uLoginDSRow
    ds1 = uloginAdapter1.GetData()

    Dim k As String = abc.uName
    txtUserPassword.Text = k

End Sub

This video shows how to work with dataset design and it has more parts. it is a youtube video link.

http://www.youtube.com/watch?v=sIgKuATsb-E

But this video not shows how to read 1 row or 1 data entry. i try some coding but getting a error

John Saunders
  • 160,644
  • 26
  • 247
  • 397
JSB
  • 215
  • 5
  • 16

1 Answers1

0

You have never assigned a value to abc.

Assuming that the GetData returns only one row, you need to do

Dim abc As loginDataSet.uLoginDSRow
ds1 = uloginAdapter1.GetData()
abc = ds1.Rows(0)
Dim k As String = abc.uName
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Thank you thank you thank you very much John. it is working now .. im trying to solve it from 3 days... thank you very much for help – JSB Nov 27 '11 at 09:12
  • `NullReferenceException` always means the same thing. See http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net. – John Saunders Nov 27 '11 at 09:28
  • Hello John I want to know some info about .Fill() What is the use of uloginAdapter1.Fill() and how to work with it , can you give me a small example of it. thank you – JSB Nov 27 '11 at 16:48
  • @JasbirBhinder: that's a separate question. Please ask a new, _focused_ question if you want to know something specific about Fill. – John Saunders Nov 27 '11 at 18:26