当我使用MS DTC时,我得到NpgsqlException(0x80004005)。
Npgsql.NpgsqlException(0x80004005):未提供密码,但后端需要一个密码(在MD5中)
以下是代码示例。
string strcon1 = "Server=localhost;Port=5432;User Id=postgres; Password=xxxxx; Database=db1;enlist=true;";
string strcon2 = "Server=localhost;Port=5432;User Id=postgres; Password=xxxxx; Database=db2;enlist=true;";
using (TransactionScope tx = new TransactionScope())
{
using (NpgsqlConnection conn1 = new NpgsqlConnection(strcon1))
{
string sql = "insert into test1(col1) values('A')";
conn1.Open();
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn1))
{
command.ExecuteNonQuery();
}
using (NpgsqlConnection conn2 = new NpgsqlConnection(strcon2))
{
conn2.Open();
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn2))
{
command.ExecuteNonQuery();
}
}
}
tx.Complete();
} // Error: tx.Dispose()
Server stack trace:
Npgsql.NpgsqlConnector.ProcessAuthenticationMessage(String username, AuthenticationRequestMessage msg)
Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout)
Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout)
Npgsql.NpgsqlConnection.OpenInternal()
Npgsql.NpgsqlTransactionCallbacks.GetConnection()
Npgsql.NpgsqlTransactionCallbacks.PrepareTransaction()
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
Npgsql.INpgsqlTransactionCallbacks.PrepareTransaction()
Npgsql.NpgsqlResourceManager.DurableResourceManager.Prepare(PreparingEnlistment preparingEnlistment)
System.Transactions.Oletx.OletxEnlistment.PrepareRequest(Boolean singlePhase, Byte[] prepareInfo)
System.Transactions.Oletx.OletxTransactionManager.ShimNotificationCallback(Object state, Boolean timeout)
System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)</StackTrace><ExceptionString>Npgsql.NpgsqlException (0x80004005): No password has been provided but the backend requires one (in MD5)
Server stack trace:
Npgsql.NpgsqlConnector.ProcessAuthenticationMessage(String username, AuthenticationRequestMessage msg)
Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout)
Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout)
Npgsql.NpgsqlConnection.OpenInternal()
Npgsql.NpgsqlTransactionCallbacks.GetConnection()
Npgsql.NpgsqlTransactionCallbacks.PrepareTransaction()
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]&amp; outArgs)
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
Npgsql.INpgsqlTransactionCallbacks.PrepareTransaction()
Npgsql.NpgsqlResourceManager.DurableResourceManager.Prepare(PreparingEnlistment preparingEnlistment)
System.Transactions.Oletx.OletxEnlistment.PrepareRequest(Boolean singlePhase, Byte[] prepareInfo)
System.Transactions.Oletx.OletxTransactionManager.ShimNotificationCallback(Object state, Boolean timeout)
System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)
Windows Server 2012 R2标准, PostgreSQL 9.6, Npgsql 3.1.8
我该如何解决?
答案 0 :(得分:-1)
尝试
date
答案 1 :(得分:-2)
解决方案是覆盖代码中的dput(max(0L,getOption("digits")-log10(3162277)))
#0.500000090664876
dput(max(0L,getOption("digits")-log10(3162278)))
#0.499999953328896
out[7] <- 3162277
out
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# 0.0 0.0 0.0 0.3 1.0 1.0 3162277
out[7] <- 3162278
out
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# 0 0 0 0 1 1 3162278
。