I don't know how you are getting that error.
According to the details provided by MSDN on the
SqlDataAdapter.Fill method:
If a command does not return any rows, no tables are added to the DataSet, and no exception is raised
The only thing I can think of is that an error/exception is encountered while populating the data tables during the Fill process.
If this is expected, then you should make use of a Try Catch block:
-
Try
-
strCommand = "Select * from view"
-
objConnection = New SqlClient.SqlConnection(strconnect)
-
objCommand = New SqlClient.SqlDataAdapter(strCommand, objConnection)
-
objCommand.Fill(dsDataSet, "view")
-
Catch ex As Exception
-
'This is the case when "view" was invalid
-
End Try
-
Because you said that you cannot implement your own error handling, I would recommend trying to add the "view" table to the SqlAdapter before filling it:
-
Dim dsDataSet As New DataSet
-
dsDataSet.Tables.Add("view")
-
-
strCommand = "Select * from view"
-
objConnection = New SqlClient.SqlConnection(strconnect)
-
objCommand = New SqlClient.SqlDataAdapter(strCommand, objConnection)
-
objCommand.Fill(dsDataSet, "view") 'Fills "view", which exists in the DataSet.
-
-
If this doesn't work, use the Try Catch block.