
-
Loading...
-
zahid.ali
- Joined on 05-08-2008, 5:52 AM
- Posts 11
|
Hi,
I am trying to connect with mysql server
this is my source code for creating a connection and requesting data
1 string provider = "System.Data.Odbc"; 2 string connectionString = "Driver={MySQL ODBC 3.51 Driver};server=localhost;Database=aiuser;user=******;password=******"; 3 DbProviderFactory factory = DbProviderFactories.GetFactory(provider); 4 DbConnection con = factory.CreateConnection(); 5 con.ConnectionString = connectionString; 6 7 DbCommand cmd = factory.CreateCommand(); 8 cmd.Connection = con; 9 cmd.CommandText = "SELECT Username, Password FROM users WHERE Username=" + "'" + username + "'" + ";"; 10 DbDataAdapter da = factory.CreateDataAdapter(); 11 da.SelectCommand = cmd; 12 13 DataSet s = new DataSet(); 14 da.Fill(s);
I have installed MySQL ODBC 3.51 Driver. I have no idea why in exception its saying SQL server 2005
i have mysql server 5.0 installed. I successfully installed this web application on windows server 2003 but now i am trying
to install this application on some different server.
this is my web.config. it still has connectionstring but i am not using it , rest of the xml is for ajax. i am using .net v 2.0
1 2 <!-- 3 Note: As an alternative to hand editing this file you can use the 4 web admin tool to configure settings for your application. Use 5 the Website->Asp.Net Configuration option in Visual Studio. 6 A full list of settings and comments can be found in 7 machine.config.comments usually located in 8 \Windows\Microsoft.Net\Framework\v2.x\Config 9 --> 10 <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 11 <configSections> 12 <sectionGroup name="system.web.extensions" 13 type="System.Web.Configuration.SystemWebExtensionsSectionGroup, 14 System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 15 PublicKeyToken=31bf3856ad364e35"> 16 <sectionGroup name="scripting" 17 type="System.Web.Configuration.ScriptingSectionGroup, 18 System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 19 PublicKeyToken=31bf3856ad364e35"> 20 <section name="scriptResourceHandler" 21 type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, 22 System.Web.Extensions, Version=1.0.61025.0, 23 Culture=neutral, PublicKeyToken=31bf3856ad364e35" 24 requirePermission="false" 25 allowDefinition="MachineToApplication"/> 26 <sectionGroup name="webServices" 27 type="System.Web.Configuration.ScriptingWebServicesSectionGroup, 28 System.Web.Extensions, Version=1.0.61025.0, 29 Culture=neutral, PublicKeyToken=31bf3856ad364e35"> 30 <section name="jsonSerialization" 31 type="System.Web.Configuration.ScriptingJsonSerializationSection, 32 System.Web.Extensions, Version=1.0.61025.0, 33 Culture=neutral, PublicKeyToken=31bf3856ad364e35" 34 requirePermission="false" allowDefinition="Everywhere" /> 35 <section name="profileService" 36 type="System.Web.Configuration.ScriptingProfileServiceSection, 37 System.Web.Extensions, Version=1.0.61025.0, 38 Culture=neutral, PublicKeyToken=31bf3856ad364e35" 39 requirePermission="false" 40 allowDefinition="MachineToApplication" /> 41 <section name="authenticationService" 42 type="System.Web.Configuration.ScriptingAuthenticationServiceSection, 43 System.Web.Extensions, Version=1.0.61025.0, 44 Culture=neutral, PublicKeyToken=31bf3856ad364e35" 45 requirePermission="false" 46 allowDefinition="MachineToApplication" /> 47 </sectionGroup> 48 </sectionGroup> 49 </sectionGroup> 50 </configSections> 51 52 <system.webServer> 53 <validation validateIntegratedModeConfiguration="false" /> 54 <modules> 55 <add name="ScriptModule" 56 preCondition="integratedMode" 57 type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 58 </modules> 59 <handlers> 60 <remove name="WebServiceHandlerFactory-ISAPI-2.0"/> 61 <add name="ScriptHandlerFactory" verb="*" path="*.asmx" 62 preCondition="integratedMode" 63 type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 64 <add name="ScriptHandlerFactoryAppServices" verb="*" 65 path="*_AppService.axd" preCondition="integratedMode" 66 type="System.Web.Script.Services.ScriptHandlerFactory, 67 System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 68 PublicKeyToken=31bf3856ad364e35"/> 69 <add name="ScriptResource" preCondition="integratedMode" 70 verb="GET,HEAD" path="ScriptResource.axd" 71 type="System.Web.Handlers.ScriptResourceHandler, 72 System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 73 PublicKeyToken=31bf3856ad364e35" /> 74 </handlers> 75 </system.webServer> 76 77 78 79 <appSettings> 80 <add key ="provider" value ="System.Data.Odbc"/> 81 <add key="ConnectionInfo" value="Driver={MySQL ODBC 3.51 Driver};server=localhost;Database=aiuser;uid=root;pwd=123"/> 82 83 </appSettings> 84 85 <system.web> 86 <httpHandlers> 87 <remove verb="*" path="*.asmx"/> 88 <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 89 <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 90 <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/> 91 </httpHandlers> 92 <httpModules> 93 <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 94 </httpModules> 95 <pages> 96 <controls> 97 <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 98 </controls> 99 </pages> 100 <!-- 101 Set compilation debug="true" to insert debugging 102 symbols into the compiled page. Because this 103 affects performance, set this value to true only 104 during development. 105 --> 106 <compilation debug="true"> 107 <assemblies> 108 <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 109 <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation> 110 <!-- 111 The <authentication> section enables configuration 112 of the security authentication mode used by 113 ASP.NET to identify an incoming user. 114 --> 115 <authentication mode="Windows"/> 116 <!-- 117 The <customErrors> section enables configuration 118 of what to do if/when an unhandled error occurs 119 during the execution of a request. Specifically, 120 it enables developers to configure html error pages 121 to be displayed in place of a error stack trace. 122 123 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> 124 <error statusCode="403" redirect="NoAccess.htm" /> 125 <error statusCode="404" redirect="FileNotFound.htm" /> 126 </customErrors> 127 --> 128 <!-- 129 <pages enableEventValidation="false"/> --> 130 </system.web> 131 </configuration> 132 133 134 135
Server Error in '/' Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 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.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
[SqlException (0x80131904): An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739123 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +685966 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +109 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +383 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +130 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105 System.Data.SqlClient.SqlConnection.Open() +111 System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +84 System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +197 System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +1121 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42 System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +83 System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +160 System.Web.UI.WebControls.Login.AttemptLogin() +105 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
|
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
|
|