?
Solved

Error databinding when multiple user access site

Posted on 2011-09-29
6
Medium Priority
?
257 Views
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
    {
        get
        {
            if (_Instance == null)
            {
                _Instance = new DBCadView(ConfigurationManager.ConnectionStrings["PatternShop10"].ConnectionString);**(set in the webconfig)
            }
            return _Instance;
        }
    }
    public DataTable getCadView()
    {
        try
        {
            _Connection.Open();
            SqlCommand command = new SqlCommand("spps_getCadViewData", _Connection);
            command.CommandType = CommandType.StoredProcedure;
            _DataAdapter.SelectCommand = command;
            DataTable result = new DataTable();
            result.Clear();
            _DataAdapter.Fill(result);
            _Connection.Close();
            return result;

        }
        catch
        {
            _Connection.Close();
            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
0
Comment
Question by:hscast
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Accepted Solution

by:
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.
0
 

Author Comment

by:hscast
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
0
 
LVL 4

Expert Comment

by:theHollow
ID: 36817607
Hello
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?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:hscast
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


0
 
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.
0
 

Author Closing Comment

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

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

777 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