powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / помогите найти ошибку
2 сообщений из 2, страница 1 из 1
помогите найти ошибку
    #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
помогите найти ошибку
    #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
2 сообщений из 2, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / помогите найти ошибку
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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