View Full Version : web.config
kobra007
01-18-2009, 08:10 AM
I'm trying to connect my database with Visual Developer 2008 Express Edition but it doesn't work.
my web.config connection sting was:
<add name="InfoConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\InfoDatabase.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
and now I did it like this:
<add name="InfoConnectionString" connectionString="Data Source=tcp:sql2k801.discountasp.net;Initial Catalog=SQL2008_586730_aspdb;User ID=SQL2008_586730_aspdb_user;Password=password;" providerName="System.Data.SqlClient" /> What's the problem??
bruce
01-19-2009, 07:07 AM
what is the error?
Bruce
DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)
kobra007
01-19-2009, 09:42 AM
the error is:
System.Data.SqlClient.SqlException was unhandled by user code
Message="A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)"
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=20
LineNumber=0
Number=10060
Server=""
State=0
StackTrace:
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.Att emptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.Log inNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.Ope nLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ct or(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateC onnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.Creat ePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateOb ject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCrea teRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConn ection connection, ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at System.Web.UI.WebControls.SqlDataSourceView.Execut eSelect(DataSourceSelectArguments arguments)
at System.Web.UI.WebControls.SqlDataSource.Select(Dat aSourceSelectArguments arguments)
at _ClientPage.questionsList_SelectedIndexChanged(Obj ect sender, EventArgs e) in c:\Users\Servsmart\Documents\livemall-lb\ClientPage.master.cs:line 574
at _ClientPage.Help_Load(Object sender, EventArgs e) in c:\Users\Servsmart\Documents\livemall-lb\ClientPage.master.cs:line 341
at _ClientPage.Page_Load(Object sender, EventArgs e) in c:\Users\Servsmart\Documents\livemall-lb\ClientPage.master.cs:line 331
at System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
bruce
01-20-2009, 10:36 AM
i assumed you are getting this error on your home computer. I would check to make sure that your network or ISP allows port 1433 to go through.
Bruce
DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)
wisemx
01-21-2009, 01:41 AM
Hi,
Looks like you need someone to look over your sites code.
This is going to be difficult to help you post after post but I'm guessing it's a code page data conn.
Salute,
Mark
Technical Evangelist for DiscountASP.NET
Find ASP.NET code samples with my Dev Coop search tools below.
Google (http://www.google.com/coop/cse?cx=009244845836111659857%3Albvxsjj8mho)
Microsoft (http://search.live.com/macros/wisemx/aspnet/?FORM=OIJG)
DiscountASP.NET Technical Webcasts:
http://www.iis7test.com/webcasts/
My Microsoft Technical Blogs
http://weblogs.asp.net/markwisecarver/
http://blogs.windowsclient.net/wisecarver/default.aspx
kobra007
01-21-2009, 10:06 AM
you can check the error go to http://www.livemall-lb.com/LiveMall.aspx
kobra007
01-23-2009, 04:18 AM
well can u give me a code to get something from a connection please.
wisemx
01-24-2009, 12:18 PM
...Sure, an entire web.config? If so, version 2 or 3.5? (IIS6/IIS7)
Please be specific.
Salute,
Mark
Technical Evangelist for DiscountASP.NET
Find ASP.NET code samples with my Dev Coop search tools below.
Google (http://www.google.com/coop/cse?cx=009244845836111659857%3Albvxsjj8mho)
Microsoft (http://search.live.com/macros/wisemx/aspnet/?FORM=OIJG)
DiscountASP.NET Technical Webcasts:
http://www.iis7test.com/webcasts/
My Microsoft Technical Blogs
http://weblogs.asp.net/markwisecarver/
http://blogs.windowsclient.net/wisecarver/default.aspx
wisemx
01-26-2009, 01:39 AM
Hi,
I'm not an employee of DASP and do not have access to your site code but here is an updated IIS7 web.config with SMTP and example SQL settings:
[quote]
<configuration>
<configSections>
<sectionGroupname='system.web.extensions'type='Syst em.Web.Configuration.SystemWebExtensionsSectionGro up,System.Web.Extensions,Version=3.5.0.0,Culture=n eutral,PublicKeyToken=31BF3856AD364E35'>
<sectionGroupname='scripting'type='System.Web.Confi guration.ScriptingSectionGroup,System.Web.Extensio ns,Version=3.5.0.0,Culture=neutral,PublicKeyToken= 31BF3856AD364E35'>
<sectionname='scriptResourceHandler'type='System.We b.Configuration.ScriptingScriptResourceHandlerSect ion,System.Web.Extensions,Version=3.5.0.0,Culture= neutral,PublicKeyToken=31BF3856AD364E35'requirePer mission='false'allowDefinition='MachineToApplicati on'/>
<sectionGroupname='webServices'type='System.Web.Con figuration.ScriptingWebServicesSectionGroup,System .Web.Extensions,Version=3.5.0.0,Culture=neutral,Pu blicKeyToken=31BF3856AD364E35'>
<sectionname='jsonSerialization'type='System.Web.Co nfiguration.ScriptingJsonSerializationSection,Syst em.Web.Extensions,Version=3.5.0.0,Culture=neutral, PublicKeyToken=31BF3856AD364E35'requirePermission= 'false'allowDefinition='Everywhere'/>
<sectionname='profileService'type='System.Web.Confi guration.ScriptingProfileServiceSection,System.Web .Extensions,Version=3.5.0.0,Culture=neutral,Public KeyToken=31BF3856AD364E35'requirePermission='false 'allowDefinition='MachineToApplication'/>
<sectionname='authenticationService'type='System.We b.Configuration.ScriptingAuthenticationServiceSect ion,System.Web.Extensions,Version=3.5.0.0,Culture= neutral,PublicKeyToken=31BF3856AD364E35'requirePer mission='false'allowDefinition='MachineToApplicati on'/>
<sectionname='roleService'type='System.Web.Configur ation.ScriptingRoleServiceSection,System.Web.Exten sions,Version=3.5.0.0,Culture=neutral,PublicKeyTok en=31BF3856AD364E35'requirePermission='false'allow Definition='MachineToApplication'/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.net>
<mailSettings>
<smtp>
<networkhost='localhost'port='25'/>
</smtp>
</mailSettings>
</system.net>
<system.web.extensions>
<scripting>
<webServices>
<authenticationServiceenabled='true'requireSSL='fal se'/>
<profileServiceenabled='true'/>
<roleServiceenabled='true'/>
</webServices>
<scriptResourceHandlerenableCompression='true'enabl eCaching='true'/>
</scripting>
</system.web.extensions>
<appSettings/>
<connectionStrings>
<clear/>
<removename='LocalSqlServer'/>
<addname='LocalSqlServer'connectionString='DataSour ce=tcp:sql.discountasp.net;InitialCatalog=SQL_user ;UserID=SQL_user;Password=password'providerName='S ystem.Data.SqlClient'/>
<removename='userConnString'/>
<addname='userConnString'connectionString='DataSour ce=tcp:sql.discountasp.net;InitialCatalog=SQL_user ;UserID=SQL_user;Password=password'providerName='S ystem.Data.SqlClient'/>
</connectionStrings>
<system.web>
<anonymousIdentificationenabled='true'/>
<authenticationmode='None'/>
<pagestheme='main01'compilationMode='Auto'maintainS crollPositionOnPostBack='true'enableSessionState=' ReadOnly'enableViewStateMac='false'enableEventVali dation='false'>
<controls>
<addtagPrefix='asp'namespace='System.Web.UI'assembl y='System.Web.Extensions,Version=3.5.0.0,Culture=n eutral,PublicKeyToken=31BF3856AD364E35'/>
<addtagPrefix='asp'namespace='System.Web.UI.WebCont rols'assembly='System.Web.Extensions,Version=3.5.0 .0,Culture=neutral,PublicKeyToken=31BF3856AD364E35 '/>
</controls>
</pages>
<compilationdebug='false'>
<assemblies>
<addassembly='System.Core,Version=3.5.0.0,Culture=n eutral,PublicKeyToken=B77A5C561934E089'/>
<addassembly='System.Web.Extensions,Version=3.5.0.0 ,Culture=neutral,PublicKeyToken=31BF3856AD364E35'/>
<addassembly='System.Data.DataSetExtensions,Version =3.5.0.0,Culture=neutral,PublicKeyToken=B77A5C5619 34E089'/>
<addassembly='System.Xml.Linq,Version=3.5.0.0,Cultu re=neutral,PublicKeyToken=B77A5C561934E089'/>
<addassembly='System.Web.DynamicData,Version=3.5.0. 0,Culture=neutral,PublicKeyToken=31BF3856AD364E35'/>
<addassembly='System.Web.Routing,Version=3.5.0.0,Cu lture=neutral,PublicKeyToken=31BF3856AD364E35'/>
<addassembly='System.Web.Abstractions,Version=3.5.0 .0,Culture=neutral,PublicKeyToken=31BF3856AD364E35 '/>
<addassembly='System.ComponentModel.DataAnnotations ,Version=3.5.0.0,Culture=neutral,PublicKeyToken=31 BF3856AD364E35'/>
<addassembly='System.Data.Linq,Version=3.5.0.0,Cult ure=neutral,PublicKeyToken=B77A5C561934E089'/>
<addassembly='System.Data.Entity,Version=3.5.0.0,Cu lture=neutral,PublicKeyToken=B77A5C561934E089'/></assemblies>
</compilation>
<siteMapenabled='true'>
<providers>
<clear/>
<addsiteMapFile='Web.sitemap'name='AspNetXmlSiteMap Provider'type='System.Web.XmlSiteMapProvider'secur ityTrimmingEnabled='false'/>
</providers>
</siteMap>
<httpHandlers>
<removeverb='*'path='*.asmx'/>
<addverb='*'path='*.asmx'validate='false'type='Syst em.Web.Script.Services.ScriptHandlerFactory,System .Web.Extensions,Version=3.5.0.0,Culture=neutral,Pu blicKeyToken=31BF3856AD364E35'/>
<addverb='*'path='*_AppService.axd'validate='false' type='System.Web.Script.Services.ScriptHandlerFact ory,System.Web.Extensions,Version=3.5.0.0,Culture= neutral,PublicKeyToken=31BF3856AD364E35'/>
<addverb='GET,HEAD'path='ScriptResource.axd'type='S ystem.Web.Handlers.ScriptResourceHandler,System.We b.Extensions,Version=3.5.0.0,Culture=neutral,Publi cKeyToken=31BF3856AD364E35'validate='false'/>
</httpHandlers>
<httpModules>
<addname='ScriptModule'type='System.Web.Handlers.Sc riptModule,System.Web.Extensions,Version=3.5.0.0,C ulture=neutral,PublicKeyToken=31BF3856AD364E35'/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compilerlanguage='c#;cs;csharp'extension='.cs'warn ingLevel='4'type='Microsoft.CSharp.CSharpCodeProvi der,System,Version=2.0.0.0,Culture=neutral,PublicK eyToken=b77a5c561934e089'>
<providerOptionname='CompilerVersion'value='v3.5'/>
<providerOptionname='WarnAsError'value='false'/>
</compiler>
<compilerlanguage='vb;vbs;visualbasic;vbscript'exte nsion='.vb'warningLevel='4'type='Microsoft.VisualB asic.VBCodeProvider,System,Version=2.0.0.0,Culture =neutral,PublicKeyToken=b77a5c561934e089'>
<providerOptionname='CompilerVersion'value='v3.5'/>
<providerOptionname='OptionInfer'value='true'/>
<providerOptionname='WarnAsError'value='false'/>
</compiler>
</compilers>
</system.codedom>
<system.webServer>
<validationvalidateIntegratedModeConfiguration='fal se'/>
<modules>
<removename='ScriptModule'/>
<addname='ScriptModule'preCondition='managedHandler 'type='System.Web.Handlers.ScriptModule,System.Web .Extensions,Version=3.5.0.0,Culture=neutral,Public KeyToken=31BF3856AD364E35'/>
</modules>
<handlers>
<removename='WebServiceHandlerFactory-Integrated'/>
<removename='ScriptHandlerFactory'/>
<removename='ScriptHandlerFactoryAppServices'/>
<removename='ScriptResource'/>
<addname='Reserved-ReportViewerWebControl-axd'path='Reserved.ReportViewerWebControl.axd'verb ='*'type='Microsoft.Reporting.WebForms.HttpHandler 'resourceType='Unspecified'preCondition='integrate dMode'/>
<addname='ScriptHandlerFactory'verb='*'path='*.asmx 'preCondition='integratedMode'type='System.Web.Scr ipt.Services.ScriptHandlerFactory,System.Web.Exten sions,Version=3.5.0.0,Culture=neutral,PublicKeyTok en=31BF3856AD364E35'/>
<addname='ScriptHandlerFactoryAppServices'verb='*'p ath='*_AppService.axd'preCondition='integratedMode 'type='System.Web.Script.Services.ScriptHandlerFac tory,System.Web.Extensions,Version=3.5.0.0,Culture =neutral,PublicKeyToken=31BF3856AD364E35'/>
<addname='ScriptResource'preCondition='integratedMo de'verb='GET,HEAD'path='ScriptResource.axd'type='S ystem.Web.Handlers.ScriptResourceHandler,System.We b.Extensions,Version=3.5.0.0,Culture=neutral,Publi cKeyToken=31BF3856AD364E35'/>
</handlers>
<directoryBrowseenabled='false'/>
<httpProtocol>
<customHeaders>
<clear/>
<addname='X-UA-Compatible'value='IE=EmulateIE7'/>
</customHeaders>
</httpProtocol>
</system.webServer>
<runtime>
<assemblyBindingxmlns='urn:schemas-microsoft-com:asm.v1'>
<dependentAssembly>
<assemblyIdentityname='System.Web.Extensions'public KeyToken='31bf3856ad364e35'/>
[b]
</dependentAssembly>
<dependentAssembly>
<assemblyIdentityname='System.Web.Extensions.Design 'publicKeyToken='31bf3856ad364e35'/>
[b]
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.serviceModel>
[b]
<serviceBehaviors>
[b]
<serviceMetadatahttpGetEnabled='true'/>
<serviceDebugincludeExceptionDetailInFaults='false'/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<servicebehaviorConfiguration='ServiceBehavior'name ='Service'>
<endpointaddress=''binding='wsHttpBinding'contract= 'IService'>
<identity>
<dnsvalue='localhost'/>
</identity>
</endpoint>
<endpointaddress='mex'binding='mexHttpBinding'contr act='IMetadataExchange'/>
</service>
</services>
</system.serviceModel>
</configuration>
</CODE>
Technical Evangelist for DiscountASP.NET
Find ASP.NET code samples with my Dev Coop search tools below.
Google (http://www.google.com/coop/cse?cx=009244845836111659857%3Albvxsjj8mho)
Microsoft (http://search.live.com/macros/wisemx/aspnet/?FORM=OIJG)
DiscountASP.NET Technical Webcasts:
http://www.iis7test.com/webcasts/
My Microsoft Technical Blogs
http://weblogs.asp.net/markwisecarver/
http://blogs.windowsclient.net/wisecarver/default.aspx
kobra007
01-26-2009, 08:43 AM
IIS7, version 3.5
yes man web.config and if you can check my website www.livemall-lb.com/LiveMall.aspx (http://www.livemall-lb.com/LiveMall.aspx) and figure out the problem, this is the code:
ConnectionStringSettings helpString = ConfigurationManager.ConnectionStrings["InfoConnectionString"];
SqlDataSource helpSource = new SqlDataSource(helpString.ConnectionString, "SELECT Question, Answer FROM Help ORDER BY Question");
IEnumerable helpID = helpSource.Select(DataSourceSelectArguments.Empty) ; // The error occures here
foreach (DataRowView row in helpID)
{
if (row["Question"].ToString().Contains(questionsList.SelectedValue))
answerText.Text = row["Answer"].ToString();
}
thx so much
wisemx
01-27-2009, 01:53 AM
Hi,
You can not connect to the MDF on your server you must use the Attach feature in either SQL Server 2005 or 2008.
Please see Video #8: www.iis7test.com/webcasts/ (http://www.iis7test.com/webcasts/)
Salute,
Mark
Technical Evangelist for DiscountASP.NET
Find ASP.NET code samples with my Dev Coop search tools below.
Google (http://www.google.com/coop/cse?cx=009244845836111659857%3Albvxsjj8mho)
Microsoft (http://search.live.com/macros/wisemx/aspnet/?FORM=OIJG)
DiscountASP.NET Technical Webcasts:
http://www.iis7test.com/webcasts/
My Microsoft Technical Blogs
http://weblogs.asp.net/markwisecarver/
http://blogs.windowsclient.net/wisecarver/default.aspx
kobra007
01-27-2009, 10:21 AM
no man this is not the problem, i know how to use the .mdf upload tools, but the problem is when working with a local database my website works correctly.
but when connecting to discountasp.net database it give me an error!!!!!
if someone can help me please it's very important.
kobra007
01-27-2009, 12:59 PM
thx man so much my web.config is correct, so the problem is from the above code.
can you please correct it to me.
when i connect to a local database (.mdf) it works, when connection to my discountasp.net database it gave me the error above :(
wisemx
01-28-2009, 12:56 PM
Hi,
If you want me to try and figure this out for you by taking a look at your site code PM me with your Control Panel login info.
Other than that I can't offer much help with this. (Actually none of us can unless we take a look for you.)
Salute,
Mark
Technical Evangelist for DiscountASP.NET
Find ASP.NET code samples with my Dev Coop search tools below.
Google (http://www.google.com/coop/cse?cx=009244845836111659857%3Albvxsjj8mho)
Microsoft (http://search.live.com/macros/wisemx/aspnet/?FORM=OIJG)
DiscountASP.NET Technical Webcasts:
http://www.iis7test.com/webcasts/
My Microsoft Technical Blogs
http://weblogs.asp.net/markwisecarver/
http://blogs.windowsclient.net/wisecarver/default.aspx
vBulletin® ©Jelsoft Enterprises Ltd.