473,394 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Webpage needs to detect that a SQL View is bad before getting an error.

denny1824
On the webpage I use a view to fill a dataset.

Expand|Select|Wrap|Line Numbers
  1. strCommand = "Select * from view"
  2. objConnection = New SqlClient.SqlConnection(strconnect)
  3. objCommand = New SqlClient.SqlDataAdapter(strCommand, objConnection)
  4. objCommand.Fill(dsDataSet, "view")
This worked fine until the DBA messed up the view. Then my page got an error when it tried to do the fill. I need a way for my webpage to detect if the view is good or bad before getting an error so that if the DBA messes up a view again that the webpage doesn't get an error.

Error handling is setup in a specific way on the page already, so that I am not allowed to handle this specific error in a different way than the rest of the possible errors. So, I need to detect that it is a bad view before I get an error.

The webpage is in VB.Net.

Thank You
Mar 31 '09 #1
6 1382
Frinavale
9,735 Expert Mod 8TB
What is the error?

-Frinny
Mar 31 '09 #2
The error is "The IListSource does not contain any data sources."

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The IListSource does not contain any data sources.
Mar 31 '09 #3
Frinavale
9,735 Expert Mod 8TB
What line does this error occur on?
Could you please post the code where this error occurs?
Mar 31 '09 #4
I already posted the code. The error happens on the last line (line 4). The .Fill causes an error when the view is bad. A bad view is one that tries to access a field that no longer exists in the table.

I need a way to know that the view is bad before I get to line 4 and it gets the error.

Thank You
Mar 31 '09 #5
Frinavale
9,735 Expert Mod 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Try
  2.     strCommand = "Select * from view"
  3.     objConnection = New SqlClient.SqlConnection(strconnect)
  4.     objCommand = New SqlClient.SqlDataAdapter(strCommand, objConnection)
  5.     objCommand.Fill(dsDataSet, "view")
  6. Catch ex As Exception
  7.    'This is the case when "view" was invalid
  8. End Try
  9.  
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:
Expand|Select|Wrap|Line Numbers
  1.     Dim dsDataSet As New DataSet
  2.     dsDataSet.Tables.Add("view")
  3.  
  4.     strCommand = "Select * from view"
  5.     objConnection = New SqlClient.SqlConnection(strconnect)
  6.     objCommand = New SqlClient.SqlDataAdapter(strCommand, objConnection)
  7.     objCommand.Fill(dsDataSet, "view") 'Fills "view", which exists in the DataSet.
  8.  
  9.  
If this doesn't work, use the Try Catch block.
Mar 31 '09 #6
Adding the view as a table before doing the fill fixed the error on the page.
Expand|Select|Wrap|Line Numbers
  1. dsDataSet.Tables.Add("view")
Thank You
Apr 3 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: David Walker | last post by:
Hi I have a program which I need to interface with a webpage - the webpage will accept an input (probably a 'post' string from the program) and then will process it and needs to return a value. ...
9
by: YZK | last post by:
Hello. I'm not a Web developer, just a user, and I think I may have somehow messed myself up majorly. I'm not quite sure how. Right now, javascript used by websites I go to either does not work at...
3
by: Richard Thornley | last post by:
Hello, I was just been given a project and I have some questions on how to accomplish the first part of the task. If a user sends an email to a specific email address I need to detect...
10
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung...
2
by: Sam | last post by:
Hi all I have a web page that allows user to referenced a stylesheet on my local network. Is there a way to detect the background color of this webpage? If I know the stylesheet that was used to...
2
by: Curtiosity | last post by:
I have done a create or replace view called creditcard1. If I do a "select * from creditcard1" it retrieves the data just fine. If I try to do a statement where I am listing the column names it...
22
by: baluMunugoti | last post by:
Hi to all I have done one webcam project which will supports view live webcam images.I am using "ENTER USB 2.0" locally its working fine..when i upload it to the webserver and test with client...
3
by: =?GB2312?B?zPC5zw==?= | last post by:
Howdy, all, I want to use python to detect the accessibility of website. Currently, I use urllib to obtain the remote webpage, and see whether it fails. But the problem is that the webpage may be...
0
by: levi2713 | last post by:
We have IP cameras that we can view by putting the IP address in a web browser. This is a control panel type webpage, but I can go a step further and go to http://<ip address>/capture.html and it...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.