Google Distance API Error: System.Data.DataTableCollection.this[string].get returned Nothing

on Oct 11, 2021 05:05 AM

Getting Following Error:

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

System.Data.DataTableCollection.this[string].get returned Nothing.

Dim origin As String = "BHAVNAGAR"
Dim destination As String = "VARTEJ"
Dim url As String = "" & origin & "&destinations=" & destination & "&key=AIzaSyAEgQTA4G4hkvQ0_WPSQdBPfWojqqaUNDQ"
Dim request As WebRequest = WebRequest.Create(url)
Using response As WebResponse = CType(request.GetResponse(), HttpWebResponse)
    Using reader As StreamReader = New StreamReader(response.GetResponseStream(), Encoding.UTF8)
        Dim dsResult As DataSet = New DataSet()
        txtDeliveryCharge.Text = dsResult.Tables("duration").Rows(0)("text").ToString()
        txtkm.Text = dsResult.Tables("distance").Rows(0)("text").ToString()
    End Using
End Using


Download FREE API for Word, Excel and PDF in ASP.Net: Download