帮助伙伴,
我是使用Xamarin Android的新手。我正在尝试将MySQL数据库连接到我的应用程序。它停在the con.Open();
行,我不确定是什么问题。
string myConnectionString = "Server=db4free.net;Port=3306;Database=*******;Uid=*******;Pwd=*******";
MySqlConnection con = new MySqlConnection(myConnectionString);
if (con.State == ConnectionState.Closed)
{
con.Open(); //error here
}
我已经添加了库
using System.Data;
using MySql.Data.MySqlClient;
我还导入了MySQLConnector
Nugget包。
我仍然在连接部分,因为我还没有做任何事情。
请注意,凭据是正确的,因为我可以使用php页面在数据库中进行连接。任何想法?
修改
在我的Catch()
上出现此错误System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL
at /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/external/boringssl/ssl/handshake_client.c:808
at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00038] in <5a97d41d36694fb19855c17429527b10>:0
at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) [0x0003e] in <5a97d41d36694fb19855c17429527b10>:0
at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus)
at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <5a97d41d36694fb19855c17429527b10>:0
at Mono.Net.Security.AsyncProtocolRequest+<ProcessOperation>d__24.MoveNext () [0x000ff] in <5a97d41d36694fb19855c17429527b10>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at Mono.Net.Security.AsyncProtocolRequest+<StartOperation>d__23.MoveNext () [0x0008b] in <5a97d41d36694fb19855c17429527b10>:0
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
at Mono.Net.Security.MobileAuthenticatedStream+<ProcessAuthentication>d__47.MoveNext () [0x00254] in <5a97d41d36694fb19855c17429527b10>:0 }
base: {System.SystemException}