Pipe error 40 A network-related or instance-specific error occurred while establishing a connection to SQL Server - sql-server-2008

This error is odd because I can connect to my server, however during normal use of my application I occasionally will get this error for 15 minutes. Eventually , thing will go back to normal. Shortly after that, the error begin to appear again. I have read many post that claim the issue is with the connectionstring and username/password. However, since I can connect to it sometimes, it cannot be my username and password. Is it possible that my application does not close streams and thus creating a bottleneck? I really have no idea.
{
ExceptionMessage = "The underlying provider failed on Open.";
ExceptionType = "System.Data.Entity.Core.EntityException";
InnerException = {
ExceptionMessage = "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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)";
ExceptionType = "System.Data.SqlClient.SqlException";
InnerException = {
ExceptionMessage = "Access is denied";
ExceptionType = "System.ComponentModel.Win32Exception";
Message = "An error has occurred.";
StackTrace = "<null>";
};
Message = "An error has occurred.";
StackTrace = " at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
\n at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
\n at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
\n at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
\n at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
\n at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
\n at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
\n at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
\n at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
\n at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
\n at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
\n at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
\n at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
\n at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
\n at System.Data.SqlClient.SqlConnection.Open()
\n at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<Open>b__36(DbConnection t, DbConnectionInterceptionContext c)
\n at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
\n at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
\n at System.Data.Entity.Core.EntityClient.EntityConnection.<Open>b__2()
\n at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
\n at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
\n at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
\n at System.Data.Entity.Core.EntityClient.EntityConnection.Open()";
};
Message = "An error has occurred.";
StackTrace = " at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__1.MoveNext()
\n--- End of stack trace from previous location where exception was thrown ---
\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()";
}

The problem was I was not closing my socket connections.

Related

Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not

I'm having an issue when I try to scaffold from my database. I keep getting the same error and I've traid everything. I enabled the TCP/IP port MYSQLEXPRESS, I reestarted de service, I tried changing the connection string on the scaffolding comand...
Here is the error I keep getting:
Microsoft.Data.SqlClient.SqlException (0x80131904): 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 - Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder.)
---> System.ComponentModel.Win32Exception (10060): Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder.
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.Open()
at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, DatabaseModelFactoryOptions options)
at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:10060,State:0,Class:20
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 - Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder.)
My database is located in an external server and I have connected to it by adding a linked server on Microsoft SQL Management Studio:
Here is the command I have been trying on the package manager console:
Scaffold-DbContext "Data Source=82.223.2.171,1433;Initial Catalog=db_crijoya;User ID=user;Password=****” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Scaffold-DbContext "Server=82.223.2.171;Database=db;User Id=user;Password=****" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Scaffold-DbContext "Server=DESKTOP-M50KV5N\SQLEXPRESS;Database=db_crijoya;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Scaffold-DbContext "Server=CRISOFT;Database=db_crijoya;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
I don't know how to solve it. I can connect properly to the server but I the scaffold command isn't working... Please help
If someone is having the same issue I just solved it.
I have my database in mysql server not sql. I was using on my command the package Microsoft.EntityFrameworkCore.SqlServer so It wouldn't do the scaffolding. I installed MySql.Data.EntityFrameworkCore, although it has fallen into disuse and tried this command:
Scaffold-DbContext "server=82.223.2.171;port=3306;user=user;password=****;database=db" MySql.Data.EntityFrameworkCore -OutputDir Models -f

SQL Server Database deployed to a server to be used in a web app:

I am developing a web app...and instead of creating the web apps database using MySQL Databases from the provider. Can I just use the SQL Server Database that I can add to the site in Visual Studio? I vaguely remember this not working and I had to result to using the providers MySQL Database through the phpmyadmin.
I go this error.
The system cannot find the file 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.ComponentModel.Win32Exception: The system cannot find the file specified
Source Error:
Line 18: {
Line 19: SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["userDataConnectionString"].ConnectionString);
Line 20: conn.Open();
Line 21: string checkuser = "select count(*) from UserData where Username='" + TextBoxUN.Text + "'";
Line 22: SqlCommand com = new SqlCommand(checkuser, conn);
Source File: C:\inetpub\wwwroot\motorcity3d.com\www\Registration.aspx.cs Line: 20
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file specified]
[SqlException (0x80131904): 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: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) +1431
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1085
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +70
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +964
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +109
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1529
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +156
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +258
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +312
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) +202
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +413
System.Data.SqlClient.SqlConnection.Open() +128
Registration.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\motorcity3d.com\www\Registration.aspx.cs:20
System.Web.UI.Control.OnLoad(EventArgs e) +106
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3062.0

ASP.NET connection to MySQL database hosted by Plesk

I have been trying to establish a connection to a database I built on Plesk, I have been having problems and am uncertain how to resolve my connectivity issue. Any assistance would be greatly appreciated, and please be as detailed as possible.
[From what I have seen online it appears I might need to install some MySQL connector, but I am unaware of how to set that up on my web server]
I created the database 'mydatabase' as a MySQL database which I built using the phpmyadmin.
Once I had the table created and ready I wanted to test the connection from my ASP.NET web application to the db by simply inserting a string set to populate a single row in the database.
I copied the connection string supplied via plesk into my web.config
<connectionStrings>
<add name="prodTbl" connectionString="Server=localhost;Database=mydatabase;Uid=admin;Pwd=password;" />
</connectionStrings>
and then I configured the following connection code in my ASPX page;
Try
Dim ProdConn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("prodTbl").ConnectionString)
Dim ProdCom As New SqlCommand With {.Connection = ProdConn}
Dim ProdRdr As SqlDataReader
ProdConn.Open()
ProdCom.CommandText = "INSERT INTO Products (CompanyID, CompanyName, ProdName, ProdCategory, ProdStatus, ProdActiveDate, ProdIActiveDate, ProdPrice, ProdCoupons, ProdDiscount, ProdDiscountStart, ProdDiscountEnd, ProdOptions, ProdImages, Nutrition, NutServSize, NutCalories, NutCalfromFat, NutTotalFatGram, NutTotalFatPercnt, NutSatFatGram, NutSatFatPercnt, NutCholMg, NutSodMg, NutSodPercnt, NutTotCarbGram, NutTotaCarbPercnt, NutDietFibGram, NutDietFibPercnt, NutSugarGram, NutProteinGram, NutVitA, NutVitC, NutCalcium, NutIron) VALUES (#Cid, #CNme, #PNme, #Pcate, #Pstatu, #PAcDt, #IAcDt, #PPrice, #PCoupons, #PDiscnt, #PDiscntS, #PDiscntE, #POptions, #PImages, #Nutr, #ServSize, #Calories, #CalfFat, #TotalFat, #TotalFatP, #SatFat, #SatFatP, #Choles, #Sodium, #SodiumP, #TotalCarb, #TotalCarbP, #DietFiber, #Sugar, #Protein, #VitaminA, #VitaminC, #Calcium, #Iron)"
ProdCom.Parameters.AddWithValue("#Cid", "12345")
ProdCom.Parameters.AddWithValue("#CNme", "TestCompany")
ProdCom.Parameters.AddWithValue("#PNme", "Pancakes")
ProdCom.Parameters.AddWithValue("#Pcate", "Breakfast")
ProdCom.Parameters.AddWithValue("#Pstatu", "Active")
ProdCom.Parameters.AddWithValue("#PAcDt", "")
ProdCom.Parameters.AddWithValue("#IAcDt", "")
ProdCom.Parameters.AddWithValue("#PPrice", 5.5)
ProdCom.Parameters.AddWithValue("#PCoupons", "")
ProdCom.Parameters.AddWithValue("#PDiscnt", 0.25)
ProdCom.Parameters.AddWithValue("#PDiscntS", "")
ProdCom.Parameters.AddWithValue("#PDiscntE", "")
ProdCom.Parameters.AddWithValue("#POptions", "Maple Syrup; Blueberries")
ProdCom.Parameters.AddWithValue("#PImages", "BreakfastPancakes.jpg")
ProdCom.Parameters.AddWithValue("#Nutr", "Y")
ProdCom.Parameters.AddWithValue("#ServSize", "1")
ProdCom.Parameters.AddWithValue("#Calories", "2")
ProdCom.Parameters.AddWithValue("#CalfFat", "1")
ProdCom.Parameters.AddWithValue("#TotalFat", "2")
ProdCom.Parameters.AddWithValue("#TotalFatP", "1")
ProdCom.Parameters.AddWithValue("#SatFat", "2")
ProdCom.Parameters.AddWithValue("#SatFatP", "1")
ProdCom.Parameters.AddWithValue("#Choles", "2")
ProdCom.Parameters.AddWithValue("#Sodium", "1")
ProdCom.Parameters.AddWithValue("#SodiumP", "2")
ProdCom.Parameters.AddWithValue("#TotalCarb", "1")
ProdCom.Parameters.AddWithValue("#TotalCarbP", "2")
ProdCom.Parameters.AddWithValue("#DietFiber", "1")
ProdCom.Parameters.AddWithValue("#Sugar", "2")
ProdCom.Parameters.AddWithValue("#Protein", "1")
ProdCom.Parameters.AddWithValue("#VitaminA", "2")
ProdCom.Parameters.AddWithValue("#VitaminC", "1")
ProdCom.Parameters.AddWithValue("#Calcium", "2")
ProdCom.Parameters.AddWithValue("#Iron", "1")
ProdCom.ExecuteNonQuery()
ProdConn.Close()
Catch ex As Exception
Response.Write("<br /><br /><br /><br />FAILURE<br />" & ex.ToString)
End Try
End Sub
Although I keep receiving the following error on my exception catch;
System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'admin'. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at ASP.admin_beoocatalog_aspx.dataRead(Object sender, EventArgs ea) in D:\InetPub\vhosts\becub3d.com\httpdocs\admin\BeOOCatalog.aspx:line 110 ClientConnectionId:ec0f7729-6d1b-488c-800a-d3fe4fb51055 Error Number:18456,State:1,Class:14
Have you tried adding port on your connection string? localhost:3306 (3306 is default port for mysql)
<connectionStrings>
<add name="prodTbl" connectionString="Server=localhost:3306;Database=mydatabase;Uid=admin;Pwd=password;" />
</connectionStrings>
Or you can try adding provider name in the web.config like below:
<connectionStrings>
<add name="dbCon" connectionString="Server=localhost:3306;Database=mydatabase;Uid=admin;Pwd=password;" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
then calling it this way:
Using mysqlConn As New MySqlConnection(ConfigurationManager.ConnectionStrings("dbCon").ConnectionString))
'Your Database Code here'
End Using

Custom Windows Service conflicting with Microsoft.ACE.OLEDB.12.0

I have an SSIS package that uses the Microsoft.ACE.OLEDB.12.0 provider to read information from tab delimited text files. There is a script task in the package that has some code like so:
DataTable dtFiles = new DataTable();
string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileInfoLocation + ";Extended Properties=\"text;HDR=NO;FMT=TabDelimited\"";
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM RepairFiscalYears.txt", connStr);
adapter.Fill(dtFiles);
This package runs as a local user, lets say UserA. Recently, a co-worker created a Windows Service on the same box the SSIS package runs on. The service's "Log on As" is set to the same UserA as the SSIS package runs. Now when I try to run the SSIS package I get the following error on the adapter.Fill(dtFiles) line.
EXCEPTION THROWN: 12/31/2014 3:04:06 AM
Unspecified error
Source: Microsoft Access Database Engine
HelpLink:
StackTracee: at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at ST_ee4c7bf65c87474397e28ea0f96c53d9.ScriptMain.Main()
If I stop the service and run the package it works fine. If I re-start the service and run the package it fails so I can easily reproduce the issue. Why does a Windows Service running under the same user as the SSIS package cause this conflict with the OLEDB provider?
Keep in mind that the Windows Service does nothing related to the package, i.e. doesn't read/write from any of the same locations/files/etc.
Any help is much appreciated.

OData Underlying Provider Failed on Open periodically

I have written an OData service with an EF4 model. It's currently fully functional and deployed on at least 30 different servers. The error is occuring on one of those servers but only periodically.
The server is configured and working.
At some random point it starts responding with 500 internal server errors.
The errors aren't being handled by the HandleException method that is implemented in the service.
The exception is instead dumping straight into the Windows EventLog under Application as a warning from ASP.NET 4.0.
The contents of the warning indicate that the problem is caused by the underlying provider failing on open (I'll post the full exception details at the end of the question).
When the errors are occuring I start up SQL Server Management Studio and can connect to the database without problem.
The solution to get the service working again is to simply recycle the application pool in IIS, but this is happening 2 or 3 times a week and is causing my client grief. Can anyone point me in the right direction as to what might be causing this? The server is possibly the most underpowered system running the service and I've recommended a RAM increase as a starting point to potentially solve the problem but I'm flying blind here.
The full exception details:
Exception information:
Exception type: EntityException
Exception message: The underlying provider failed on Open.
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open()
at ColdFusion.Service.Authenticate.BasicAuthenticationProvider..cctor()
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
at System.Data.SqlClient.TdsParserStateObject.ReadByte()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)