Traitée adapter.Fill(dataSet) Error

  • Saturday, July 14, 2012 3:30 PM
     
      Has Code

    I have a DataSet error with my project. I paid someone to develop the code and I am now learning to write code myself. The project worked once when it was on the VPS, but now that I have the project on my local I have this dataset error. I can run the project and signup a new user when the project is first built, but when I try to log back in with the user I get the error below. It seems that I am staying logged in or something. Not really sure what the problem is. Can someone please help?

    -- Error (Code is below this)

    ------------------------------------------------------------------------------

    System.Data.SqlClient.SqlException was unhandled by user code

      Message=Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

      Source=.Net SqlClient Data Provider

      ErrorCode=-2146232060

     >

      LineNumber=0

      Number=-2

      Procedure=""

      Server=tcp:ofzdmpjaxm.database.windows.net,1433

      State=0

      StackTrace:

           at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

           at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

           at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()

           at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

           at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()

           at System.Data.SqlClient.SqlDataReader.get_MetaData()

           at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

           at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

           at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

           at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)

           at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)

           at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

           at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)

           at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

           at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

           at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)

           at Wilson.ORMapper.Internals.Connection.GetDataSet(Type entityType, CommandInfo commandInfo, DataSet dataSet, String sqlStatement, Parameter[] parameters) in C:\Users\JW Johnson\Documents\Visual Studio 2010\Projects\FF\OrMapper\Internals\Connection.cs:line 178

           at Wilson.ORMapper.Internals.Connection.GetDataSet(Type entityType, CommandInfo commandInfo, String sqlStatement, Parameter[] parameters) in C:\Users\JW Johnson\Documents\Visual Studio 2010\Projects\FF\OrMapper\Internals\Connection.cs:line 163

           at Wilson.ORMapper.ObjectSpace.GetDataSet(String sqlStatement) in C:\Users\JW Johnson\Documents\Visual Studio 2010\Projects\FF\OrMapper\ObjectSpace.cs:line 821

           at iFitness.BLL.Users.GetWorkout(Int32 userid, Panel pnlExercise, Panel pnlFinished, Label lblFinished, Page page, Boolean userEquip) in C:\Users\JW Johnson\Documents\Visual Studio 2010\Projects\FF\iFitness.BLL\Users.cs:line 276

           at iFitness.mobileTrainer.LoadExercise(Boolean noEquip) in C:\Users\JW Johnson\Documents\Visual Studio 2010\Projects\FF\iFitness\Secured\mobileTrainer.aspx.cs:line 47

           at iFitness.mobileTrainer.Page_Load(Object sender, EventArgs e) in C:\Users\JW Johnson\Documents\Visual Studio 2010\Projects\FF\iFitness\Secured\mobileTrainer.aspx.cs:line 34

           at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

           at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)

           at System.Web.UI.Control.OnLoad(EventArgs e)

           at System.Web.UI.Control.LoadRecursive()

           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

      InnerException:

    --- Code that leads up to error

    -------------------------------------------------------------

    //**************************************************************//
    // Paul Wilson -- www.WilsonDotNet.com -- Paul@WilsonDotNet.com //
    // Feel free to use and modify -- just leave these credit lines //
    // I also always appreciate any other public credit you provide //
    //**************************************************************//
    // Commands now inherit the connection timeout for long-running queries
    // Fix for Providers without Timeouts by Stephan Wagner (http://www.calac.net)
    using System;
    using System.Data;
    using System.Diagnostics;
    using Wilson.ORMapper.Query;
     
    namespace Wilson.ORMapper.Internals
    {
    	internal class Connection
    	{
    		public static readonly string SplitToken = "<$>";
    		private string connection;
    		private CustomProvider provider;
    		private int commandTimeout;
    		private bool supportsTimeout = true;
    		private IInterceptCommand interceptor = null;
     
    		public void SetInterceptor(IInterceptCommand interceptor) {
    			this.interceptor = interceptor;
    		}
     
    		internal Connection(string connectString, CustomProvider customProvider) {
    			if (connectString == null || connectString.Length == 0) {
    				throw new ORMapperException("Internals: ConnectionString was Empty");
    			}
    			if (customProvider.Provider == Provider.Access && connectString.ToUpper().IndexOf("PROVIDER") < 0) {
    				this.connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connectString;
    			}
    			else {
    				this.connection = connectString;
    			}
    			this.provider = customProvider;
     
    			// Check Timeout Support and Valid Connection String
    			IDbConnection connection = null;
    			try {
    				connection = ProviderFactory.GetConnection(this.connection, this.provider);
    				this.commandTimeout = connection.ConnectionTimeout;
    				try {
    					IDbCommand command = connection.CreateCommand();
    					command.CommandTimeout = this.commandTimeout;
    				}
    				catch {
    					this.supportsTimeout = false;
    				}
    				connection.Open();
    			}
    			catch (Exception exception) {
    				throw new ORMapperException("ObjectSpace: Connection String is Invalid - " + exception.Message, exception);
    			}
    			finally {
    				if (connection != null) { connection.Close(); }
    			}
    		}
     
    		// Jeff Lanning (jefflanning@gmail.com): Added overload for OPath support
    		public IDataReader GetDataReader(Type entityType, CommandInfo commandInfo, CompiledQuery query, object[] parameterValues) {
    			IDbConnection conn = null;
    			try {
    				conn = ProviderFactory.GetConnection(this.connection, this.provider);
    				IDbCommand cmd = CreateDbCommand(Guid.NewGuid(), entityType, commandInfo, conn, query, parameterValues);
    				cmd.Connection.Open();
    				return cmd.ExecuteReader(CommandBehavior.CloseConnection);
    			}
    			catch {
    				if( conn != null ) conn.Close();
    				throw;
    			}
    		}
     
    		public IDataReader GetDataReader(Type entityType, CommandInfo commandInfo, string sqlStatement, params Parameter[] parameters) {
    			IDbCommand command = null;
    			return this.GetDataReader(entityType, commandInfo, out command, sqlStatement, parameters);
    		}
     
    		public IDataReader GetDataReader(Type entityType, CommandInfo commandInfo, out IDbCommand dbCommand, string sqlStatement, params Parameter[] parameters) {
    			IDbConnection connection = null;
    			try {
    				connection = ProviderFactory.GetConnection(this.connection, this.provider);
    				dbCommand = CreateDbCommand(Guid.NewGuid(), entityType, commandInfo, connection, sqlStatement, parameters);
    				connection.Open(); // Must Close DataReader to Close Connection
    				return dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
    			}
    			catch {
    				if (connection != null) { connection.Close(); }
    				throw;
    			}
    		}
     
    		public object GetScalarValue(Type entityType, CommandInfo commandInfo, string sqlStatement, params Parameter[] parameters) {
    			string sqlStatement1 = sqlStatement;
    			string sqlStatement2 = null;
    			int splitIndex = sqlStatement.IndexOf(Connection.SplitToken);
    			if (splitIndex >= 0) {
    				sqlStatement1 = sqlStatement.Substring(0, splitIndex);
    				sqlStatement2 = sqlStatement.Substring(splitIndex + Connection.SplitToken.Length);
    			}
     
    			object value = null;
     
    			using (IDbConnection connection = ProviderFactory.GetConnection(this.connection, this.provider))
    			{
    				IDbCommand command = CreateDbCommand(Guid.NewGuid(), entityType, commandInfo, connection, sqlStatement1, parameters);
    				if (this.provider.UseInsertReturn && sqlStatement.ToUpper().StartsWith("INSERT")) {
    					IDbDataParameter dbParameter = command.CreateParameter();
    					dbParameter.ParameterName = "KeyField";
    					dbParameter.DbType = DbType.Decimal;
    					dbParameter.Direction = ParameterDirection.ReturnValue;
    					command.Parameters.Add(dbParameter);
    				}
    				connection.Open(); // Connection will be Closed in all Cases
    				if (sqlStatement2 != null) {
    					bool success = (command.ExecuteNonQuery() > 0);
    					if (!success) return null;
    					command = CreateDbCommand(Guid.NewGuid(), entityType, CommandInfo.GetScalar, connection, sqlStatement2, null);
    				}
    				if (this.provider.UseInsertReturn && sqlStatement.ToUpper().StartsWith("INSERT")) {
    					if (command.ExecuteNonQuery() > 0) {
    						value = ((IDbDataParameter)command.Parameters["KeyField"]).Value;
    					}
    				}
    				else {
    					value = command.ExecuteScalar();
    				}
    				this.SetOutputParameters(command, parameters);
    			}
    			return value;
    		}
     
    		public int ExecuteCommand(Type entityType, CommandInfo commandInfo, string sqlStatement, params Parameter[] parameters) {
    			int output = 0; // Success if any Rows are Affected
     
    			using (IDbConnection connection = ProviderFactory.GetConnection(this.connection, this.provider))
    			{
    				IDbCommand command = CreateDbCommand(Guid.NewGuid(), entityType, commandInfo, connection, sqlStatement, parameters);
    				connection.Open(); // Connection will be Closed in all Cases
    				output = command.ExecuteNonQuery();
    				this.SetOutputParameters(command, parameters);
    			}
     
    			return output;
    		}
     
    		// Jeff Lanning (jefflanning@gmail.com): Added overload for OPath support
    		public DataSet GetDataSet(Type entityType, CommandInfo commandInfo, CompiledQuery query, object[] parameterValues) {
    			using (IDbConnection conn = ProviderFactory.GetConnection(this.connection, this.provider))
    			{
    				IDbCommand cmd = CreateDbCommand(Guid.NewGuid(), entityType, commandInfo, conn, query, parameterValues);
    				IDbDataAdapter adapter = ProviderFactory.GetAdapter(cmd, this.provider);
    				DataSet dataSet = new DataSet("WilsonORMapper");
    				adapter.Fill(dataSet);				
    				return dataSet;
    			}
    		}
     
    		public DataSet GetDataSet(Type entityType, CommandInfo commandInfo, string sqlStatement, params Parameter[] parameters) {
    			return this.GetDataSet(entityType, commandInfo, null, sqlStatement, parameters);
    		}
     
    		// Includes support for typed datasets from Ben Priebe (http://stickfly.com)
    		public DataSet GetDataSet(Type entityType, CommandInfo commandInfo, DataSet dataSet, string sqlStatement, params Parameter[] parameters) {
    			if (dataSet == null) dataSet = new DataSet("WilsonORMapper");
    			using (IDbConnection connection = ProviderFactory.GetConnection(this.connection, this.provider))
    			{
    				IDbCommand command = CreateDbCommand(Guid.NewGuid(), entityType, commandInfo, connection, sqlStatement, parameters);
    				IDbDataAdapter adapter = ProviderFactory.GetAdapter(command, this.provider);
    				if (dataSet.Tables.Count > 0) {
    					string tableName = dataSet.Tables[0].TableName;
    					(adapter as System.Data.Common.DbDataAdapter).Fill(dataSet, tableName);
    				}
    				else {
    					adapter.Fill(dataSet);

All Replies

  • Sunday, July 15, 2012 11:11 AM
     
     Answered Has Code

    The method

    internal Connection(string connectString, CustomProvider customProvider)

    gets the connectionString from some setting in your project.

    Basically the connectionString isn't pointing to your database thus you have to find where it is stored and modify it.


    Miha Markic [MVP C#] http://blog.rthand.com

  • Monday, July 16, 2012 1:04 PM
     
     Answered

    Firast please check your connection string it points the proper dataSouece.And check the following also

    This type of timeout can have three causes;

    1.There's a deadlock somewhere

    2.The database's statistics and/or query plan cache are incorrect

    3.The query is too complex and needs to be tuned


    With Thanks and Regards
    Sambath Raj.C
    click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you
    Happy Programming!