Error databinding when multiple user access site

Posted on 2011-09-29
Medium Priority
Last Modified: 2012-05-12
I have a website developed in VS2010 that in published on a production server and  uses a static instance of a connection string.  When multiple users try to use the site at the same time they recieve Data Binding errors.  It's like the wrong data is being returned or that the gridview is trying to bind to the wrong result set.  I can not reproduce the errors on my local machine.  I have checked the stored procedures and know that they return the correct column names.  If you let the error sit for a couple minutes or restart the program the error will disappear.  Here is how the connection string is written:
public class DBCadView
      public DBCadView(string connectionString)
            _Connection = new SqlConnection(connectionString);
        _DataAdapter = new SqlDataAdapter();
    public static DBCadView Connection
            if (_Instance == null)
                _Instance = new DBCadView(ConfigurationManager.ConnectionStrings["PatternShop10"].ConnectionString);**(set in the webconfig)
            return _Instance;
    public DataTable getCadView()
            SqlCommand command = new SqlCommand("spps_getCadViewData", _Connection);
            command.CommandType = CommandType.StoredProcedure;
            _DataAdapter.SelectCommand = command;
            DataTable result = new DataTable();
            return result;

            return null;
       private SqlDataAdapter _DataAdapter;
    private SqlConnection _Connection;
    private static DBCadView _Instance;

any help or suggestion anyone may have to eliminate these errors would be greatly appreciated.  Thank you for your time
Question by:hscast
  • 3
  • 2
LVL 40

Accepted Solution

Jacques Bourgeois (James Burger) earned 2000 total points
ID: 36817170
What is the exact type of Exception and exact message they receive?


You do not need to Open and Close the connection when you use Fill. Fill will do it automatically for you, and will take care of doing it before triggering an Exception it it happens. You need to Open and Close with a DataReader, when executing a Command object directly or when working in transaction mode. But not with Fill or FillSchema when you are executing them outside of a Transaction.

Since, by default, you can have only one operation running at a time on a connection instance, this also prevents problems should the connection not close properly somewhere.

It is also suggested to use a local variable for the Connection. As long as you use the exact same ConnectionString all the time, the connection pooling built into the SqlConnection object will manage the connection in a better way than you can.

By using the built-in mechanisms of the SqlClient class, you have less chances of a Connection keeping a lock on a table somewhere.

It could correct your problem.

Author Comment

ID: 36817569
1.  DataBinding: 'System.Data.DataRowView' does not contain a property with the name "some column name
2.  Column "some column name" does not belong to table

We are using a link server.  Some of the data is located on a 2000 server and some is located on a 2008 server

Expert Comment

ID: 36817607
How does your connection string look like?
It may be that there are some segment in the connection string that handle the locking problem.
It may also be good to take a look at the Stored Procedure that you get data from. Maybe it could need some kind of tuning?

You may also create the command from the connection instead of with the "new" keyword.
Example :
SqlCommand command = _Connection.CreateCommand();

May I see the exception that you get?
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions


Author Comment

ID: 36817671
Connection String from the web config - <add name="PatternShop10" connectionString="data source=SOYUZ;persist security info=False;user id=userid;password=pword;initial catalog=PatternShop;packet size=4096" />

error msg - DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'fdesc'.
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: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'fdesc'.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'fdesc'.]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8688109
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8
   System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable dataSource) +349
   System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +109
   System.Web.UI.WebControls.ListControl.PerformSelect() +34
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   Websites_RushList_SampleShts_RushListDefault.LoadSearch() +430
   Websites_RushList_SampleShts_RushListDefault.Page_Load(Object sender, EventArgs e) +36
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

LVL 40
ID: 36818994
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'fdesc'.

There is a control in the page that set to display the value of a field "fdesc" and this field is not part of the data fetched from the database by the spps_getCadViewData stored procedure.

You either have an extra control that is useless in the page, or the field "fdesc" was not specifier in the SQL command or stored procedure that is executed when you retrieve the data.

If the information is needed, look at the code in the stored procedure, or ask somebody to do it if you do not have access to it. If the field fdesc is not there, add it to the procedure. Or check that it is not mispelled, either in the procedure or in the part of the application where the binding is defined. The two need to match for binding to work.

Author Closing Comment

ID: 36891680
Ended up setting all the connections local and it works now, Thank you very much for your time

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question