Hi there, i would like to find out what the hell is wrong here

/// <summary>
        /// Get a single integer value
        /// </summary>
        /// <param name="sql">The sql query used to retreive a result set</param>
        /// <returns>The value of the first column in the first row of the result set as an integer</returns>
        public virtual int GetSimpleInteger( string sql )
        {
            SqlCommand comm = new SqlCommand( sql, GetConnectionObject() );
            
            try
            {
                // Reset the error object
                ClearError();

                return (Int32)comm.ExecuteScalar(); <------- Error here
            }
            catch( SqlException ex )
            {
                SetError( ex );
                return -1;
            }
        }

now the funny thing is this worked perfectly until today, i just switched my PC on and built the project straight, now also i cannot connect to SQL either...

I get this error ExecuteScalar requires an open and available Connection. The connection's current state is closed. PLEASEEEEEEEEEEEEE HELP, this is very urgent, im on deadline

Thanks

First off, thats C# and not asp. This needs to be in the ASP.NET forum.

Second, if it worked fine and then SQL Connect suddenly stops, check your database not your code.

You probably have an offline SQL database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.