I've written a connection class to use in all my files:
[code]
using System;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Data.SqlClient;
public class DataBaseConnection : Page
{
public SqlConnection connection;
public SqlConnection conn()
{
connection = new SqlConnection();
connection.ConnectionString = "Trusted_Connection = yes; initial catalog=''; data source=''; Connect Timeout=30 ";
connection.Open();
return connection;
}
}
[/code]
That is how I import it to my .aspx files:
[code]
<%@Page Inherits="DataBaseConnection" Src="Connection.cs"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
[/code]
This code is supposed to view the table called "Banks". It worked fine before when I wrote the code of connection in the file. Now, I get this error:
[code]
Exception Details: System.InvalidOperationException: ExecuteReader: Connection property has not been initialized
Line 156: reader = command.ExecuteReader();
[/code]
Anything?
Thank you.