Issue
I read the documentation on Cloud SQL here but in the solution explorer I not have appsettings.json file to put this code:
{
"CloudSQL" : {
ConnectionString": "Host=127.0.0.1;Uid=DATABASE_USER;Pwd=PASSWORD;Database=DATABASE_NAME"
}
}
Then, in your Startup.cs file, create a database connection:
var connectionString = new MySqlConnectionStringBuilder(
Configuration["CloudSql:ConnectionString"])
{
// Connecting to a local proxy that does not support ssl.
SslMode = MySqlSslMode.None,
};
DbConnection connection =
new MySqlConnection(connectionString.ConnectionString);
I use empty blank project for iOS on Visual Studio on Mac. How to connect to Cloud SQL ?
Solution
You can hard code the connectionString
in code behind:
var connectionString = new MySqlConnectionStringBuilder("Host=127.0.0.1;Uid=DATABASE_USER;Pwd=PASSWORD;Database=DATABASE_NAME")
{
// Connecting to a local proxy that does not support ssl.
SslMode = MySqlSslMode.None,
};
DbConnection connection = new MySqlConnection(connectionString.ConnectionString);
Well, it is not recommend to connect directly to a db server from a client. It's unsafe.
Answered By - nevermore
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.