Reputation: 4289
I created a managed sql instance on Google Cloud using these instructions.
I would like to connect from my code using C#.
When I write locally, this is my connection string:
public string LocalDataSource = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\Users\Bob\Desktop\versionsOfMediaPlayer\14.4.19\mediaPlayer_1\Database1.mdf';Integrated Security=True;Connect Timeout=30";
and I manage to write to local sql.
What should be my connection string for the instance on Google Cloud?
details of my instance:
ip: <MY_IP_ADDRESS>
user: postgres
password: postgres
Instance connection name: my-project:us-central1:my-sql-instance
I added my local ip to the Cloud SQL instance firewall - so I manage to connect via command line, now I'd like to do so programmatically, using C#. what should be my connection string?
Upvotes: 0
Views: 1068
Reputation: 3575
Once you have authorized your IP address to connect, connecting to Cloud SQL is the same as any other database. According the the MySQL Connector docs for C# (found here), the connection string should look like the following:
"server=<YOUR_IP_ADDRESS>;uid=postgres;pwd=postgres;database=your-database";
Upvotes: 1