0

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

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by agrothe
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.