PROBLEMAS COM STRING DE CONEXAO NO WEB.CONFIG
Estou tentando colocar a string de conexão do meu BD no web.config, mas o seguinte erro me é apresentado:
Erro de Servidor no Aplicativo [ô]/[ô].
--------------------------------------------------------------------------------
Erro de configuração
Descrição: Erro durante o processamento de um arquivo de configuração necessário para o serviço desta solicitação. Examine os detalhes especÃficos do erro e modifique esse arquivo de configuração apropriadamente.
Mensagem de Erro do Analisador: Seção de configuração não reconhecida add.
Erro de Origem:
Linha 15: </configSections>
Linha 16: <appSettings/>
Linha 17: <add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.\SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
Linha 18: <connectionStrings/>
Linha 19: <system.web>
Arquivo de Origem: C:\Users\madureira\Documents\Visual Studio 2008\Projects\Teste\Teste\web.config Linha: 17
Alguem sabe o que pode estar acontecendo ?
Abaixo o web.config:
<?xml version=[Ô]1.0[Ô]?>
<configuration>
<configSections>
<sectionGroup name=[Ô]system.web.extensions[Ô] type=[Ô]System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]>
<sectionGroup name=[Ô]scripting[Ô] type=[Ô]System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]>
<section name=[Ô]scriptResourceHandler[Ô] type=[Ô]System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô] requirePermission=[Ô]false[Ô] allowDefinition=[Ô]MachineToApplication[Ô]/>
<sectionGroup name=[Ô]webServices[Ô] type=[Ô]System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]>
<section name=[Ô]jsonSerialization[Ô] type=[Ô]System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô] requirePermission=[Ô]false[Ô] allowDefinition=[Ô]Everywhere[Ô]/>
<section name=[Ô]profileService[Ô] type=[Ô]System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô] requirePermission=[Ô]false[Ô] allowDefinition=[Ô]MachineToApplication[Ô]/>
<section name=[Ô]authenticationService[Ô] type=[Ô]System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô] requirePermission=[Ô]false[Ô] allowDefinition=[Ô]MachineToApplication[Ô]/>
<section name=[Ô]roleService[Ô] type=[Ô]System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô] requirePermission=[Ô]false[Ô] allowDefinition=[Ô]MachineToApplication[Ô]/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings/>
<add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.\SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
<connectionStrings/>
<system.web>
<compilation debug=[Ô]true[Ô]>
<assemblies>
<add assembly=[Ô]System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089[Ô]/>
<add assembly=[Ô]System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089[Ô]/>
<add assembly=[Ô]System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
<add assembly=[Ô]System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089[Ô]/>
</assemblies>
</compilation>
<authentication mode=[Ô]Windows[Ô]/>
<pages>
<controls>
<add tagPrefix=[Ô]asp[Ô] namespace=[Ô]System.Web.UI[Ô] assembly=[Ô]System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
<add tagPrefix=[Ô]asp[Ô] namespace=[Ô]System.Web.UI.WebControls[Ô] assembly=[Ô]System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
</controls>
</pages>
<httpHandlers>
<remove verb=[Ô]*[Ô] path=[Ô]*.asmx[Ô]/>
<add verb=[Ô]*[Ô] path=[Ô]*.asmx[Ô] validate=[Ô]false[Ô] type=[Ô]System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
<add verb=[Ô]*[Ô] path=[Ô]*_AppService.axd[Ô] validate=[Ô]false[Ô] type=[Ô]System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
<add verb=[Ô]GET,HEAD[Ô] path=[Ô]ScriptResource.axd[Ô] type=[Ô]System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô] validate=[Ô]false[Ô]/>
</httpHandlers>
<httpModules>
<add name=[Ô]ScriptModule[Ô] type=[Ô]System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language=[Ô]c#;cs;csharp[Ô] extension=[Ô].cs[Ô] warningLevel=[Ô]4[Ô] type=[Ô]Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089[Ô]>
<providerOption name=[Ô]CompilerVersion[Ô] value=[Ô]v3.5[Ô]/>
<providerOption name=[Ô]WarnAsError[Ô] value=[Ô]false[Ô]/>
</compiler>
</compilers>
</system.codedom>
<system.webServer>
<validation validateIntegratedModeConfiguration=[Ô]false[Ô]/>
<modules>
<remove name=[Ô]ScriptModule[Ô]/>
<add name=[Ô]ScriptModule[Ô] preCondition=[Ô]managedHandler[Ô] type=[Ô]System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
</modules>
<handlers>
<remove name=[Ô]WebServiceHandlerFactory-Integrated[Ô]/>
<remove name=[Ô]ScriptHandlerFactory[Ô]/>
<remove name=[Ô]ScriptHandlerFactoryAppServices[Ô]/>
<remove name=[Ô]ScriptResource[Ô]/>
<add name=[Ô]ScriptHandlerFactory[Ô] verb=[Ô]*[Ô] path=[Ô]*.asmx[Ô] preCondition=[Ô]integratedMode[Ô] type=[Ô]System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
<add name=[Ô]ScriptHandlerFactoryAppServices[Ô] verb=[Ô]*[Ô] path=[Ô]*_AppService.axd[Ô] preCondition=[Ô]integratedMode[Ô] type=[Ô]System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
<add name=[Ô]ScriptResource[Ô] preCondition=[Ô]integratedMode[Ô] verb=[Ô]GET,HEAD[Ô] path=[Ô]ScriptResource.axd[Ô] type=[Ô]System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35[Ô]/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns=[Ô]urn:schemas-microsoft-com:asm.v1[Ô]>
<dependentAssembly>
<assemblyIdentity name=[Ô]System.Web.Extensions[Ô] publicKeyToken=[Ô]31bf3856ad364e35[Ô]/>
<bindingRedirect oldVersion=[Ô]1.0.0.0-1.1.0.0[Ô] newVersion=[Ô]3.5.0.0[Ô]/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name=[Ô]System.Web.Extensions.Design[Ô] publicKeyToken=[Ô]31bf3856ad364e35[Ô]/>
<bindingRedirect oldVersion=[Ô]1.0.0.0-1.1.0.0[Ô] newVersion=[Ô]3.5.0.0[Ô]/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Uso no codigo da pagina:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Teste
{
public partial class _Default : System.Web.UI.Page
{
//SqlConnection conn = new SqlConnection(@[Ô]Data Source=.\SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô]);
string conn = ConfigurationManager.ConnectionStrings[[Ô]Default[Ô]].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
try
{
SqlCommand cmd = new SqlCommand([Ô]SELECT Codigo, Nome, Telefone FROM Cliente ORDER BY Nome[Ô], conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet dsClientes = new DataSet();
da.Fill(dsClientes, [Ô]Clientes[Ô]);
conn.Open();
GridView1.DataSource = dsClientes.Tables[[Ô]Clientes[Ô]];
GridView1.DataBind();
}
finally
{
conn.Close();
}
}
}
}
Desde já grato pela atenção;
Citação:JWCELYO escreveu:
mas vocÊ esta testando no servidor local da sua maquina ou em servidor web de hospedagem
local...
Muito obrigado;
Citação:
[txt-color=#ff0000] <connectionStrings>[/txt-color]
<add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.\SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
<connectionStrings/>
Citação:RAMSES escreveu:
[txt-color=#ff0000] <connectionStrings>[/txt-color]
<add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
<connectionStrings/>
Tentei retirar o <connectionStrings> mas continuou dando o mesmo erro .....
Alguém tem alguma ideia ?
Obrigado;
Citação:MADUJR escreveu:
RAMSES escreveu:
[txt-color=#ff0000] <connectionStrings>[/txt-color]
<add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
<connectionStrings/>
Tentei retirar o <connectionStrings> mas continuou dando o mesmo erro .....
Alguém tem alguma ideia ?
Obrigado;
o que ta em vermelho eh o que falta no we.config
Citação:RAMSES escreveu:
MADUJR escreveu:
RAMSES escreveu:
[txt-color=#ff0000] <connectionStrings>[/txt-color]
<add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
<connectionStrings/>
Tentei retirar o <connectionStrings> mas continuou dando o mesmo erro .....
Alguém tem alguma ideia ?
Obrigado;
o que ta em vermelho eh o que falta no we.config
ele sublinha os dois de vermelho como erro e ao tentar rodar ele traz a mensagem [Ô]Error expecting end tag </connectionStrings>.[Ô]
Obrigado;
<connectionStrings>
<add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
</connectionStrings>
Citação:RAMSES escreveu:
agora com certeza vai hahaha
<connectionStrings>
<add name=[Ô]Default[Ô] connectionString=[Ô]Data Source=.SQLEXPRESS;Initial Catalog=testedb;Integrated Security=True[Ô] providerName=[Ô]System.Data.SqlClient[Ô]/>
</connectionStrings>
Perfeito deu certo !!!!
Muito obrigado;