Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / помогите найти ошибку / 2 сообщений из 2, страница 1 из 1
09.09.2006, 22:32
    #33976113
_jek_sobakaryov_
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
помогите найти ошибку
Доброго времени суток.

Есть следующий исходник:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {              
>>>         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select id, [Name] from some_table", con);
            con.Open();
............ и т.д.

При открытии страницы на указанной знаками >>> строке вываливается ошибка:
Код: plaintext
1.
2.
3.
4.
Object reference not set to an instance of an object. 

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.NullReferenceException: Object reference not set to an instance of an object.
webconfig следующий:
Код: plaintext
1.
2.
3.
4.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
	<ConnectionStrings>
		<add name="ConnectionString1" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database1;Data Source=(local)"/>
		<add name="ConnectionString2" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database2;Data Source=(local)"/>
	</ConnectionStrings>

Что я неправильно делаю?
Используется framework 2.0

Заранее благодарен.
...
Рейтинг: 0 / 0
10.09.2006, 00:43
    #33976182
RasimS
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
помогите найти ошибку
_jek_sobakaryov_Доброго времени суток.

Есть следующий исходник:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {              
>>>         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select id, [Name] from some_table", con);
            con.Open();
............ и т.д.

При открытии страницы на указанной знаками >>> строке вываливается ошибка:
Код: plaintext
1.
2.
3.
4.
Object reference not set to an instance of an object. 

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.NullReferenceException: Object reference not set to an instance of an object.
webconfig следующий:
Код: plaintext
1.
2.
3.
4.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
	<ConnectionStrings>
		<add name="ConnectionString1" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database1;Data Source=(local)"/>
		<add name="ConnectionString2" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database2;Data Source=(local)"/>
	</ConnectionStrings>

Что я неправильно делаю?
Используется framework 2.0

Заранее благодарен.
Проверь существование базы.
...
Рейтинг: 0 / 0
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / помогите найти ошибку / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]