Google Cloud SQL for SQL Server is a fully managed relational database service that hosts Microsoft SQL Server in the cloud. It allows developers to continue using familiar SQL Server tools and existing skills while automating routine database management tasks. The service also integrates seamlessly with other Google Cloud products, such as Google Kubernetes Engine (GKE) and Cloud Functions.
For organizations that rely on Google Cloud infrastructure but want to keep the advantages of SQL Server without maintaining their own database servers, Cloud SQL for SQL Server provides a strong alternative to Azure SQL Database.
This guide explains how to connect .NET applications to SQL Server instances hosted on Google Cloud and perform essential data operations. To ensure a smooth, secure, and reliable connection without complex configuration or additional client libraries, we will use Devart's dotConnect for SQL Server, a high-performance data provider for .NET.
Why dotConnect for SQL Server?
No client libraries required
Connect to SQL Server directly via TCP/IP without installing SQL Server client software.
Full ADO.NET compliance
Leverage familiar ADO.NET interfaces and components for smooth integration and predictable behavior.
Secure and stable
Supports encrypted connections and undergoes continuous performance and security testing to meet enterprise standards.
Broad compatibility
Works across all major versions of SQL Server and supports .NET Framework, .NET Core, and .NET 5/6/7+.
IDE integration
Features native integration with Visual Studio and complete design-time support.
Priority support & frequent updates
Enjoy priority support, detailed documentation, and regular updates for continuous improvement.
Download and activate dotConnect for SQL Server
You can start using dotConnect for SQL Server immediately with a 30-day free trial. Choose one of the following installation options:
using System;
using Devart.Data.SqlServer;
partialclassProgram
{
staticvoidMain(string[] args)
{
try
{
using (var connection = GoogleSqlTest.DatabaseConnection.CreateConnection())
{
connection.Open();
Console.WriteLine("Successfully connected to SQL Server!\n");
string sql =
"UPDATE actor " +
"SET first_name = @first, last_name = @last " +
"WHERE actor_id = 51;";
using (SqlCommand command = new SqlCommand(sql, connection))
{
command.Parameters.Add(new SqlParameter("@first", "Denzel"));
command.Parameters.Add(new SqlParameter("@last", "Washington"));
int rowsAffected = command.ExecuteNonQuery();
if (rowsAffected > 0)
{
Console.WriteLine("Successfully updated actor with ID 51 to Denzel Washington.");
}
else
{
Console.WriteLine("No actor found with ID 51, or the name was already Denzel Washington.");
}
}
}
}
catch (SqlException ex)
{
Console.WriteLine($"Error connecting to database: {ex.Message}");
}
}
}
The application shows us the updated data:
Delete rows from Cloud SQL for SQL Server
Finally, let us remove the record we previously added. Use the below code:
using System;
using Devart.Data.SqlServer;
partialclassProgram
{
staticvoidMain(string[] args)
{
try
{
using (var connection = GoogleSqlTest.DatabaseConnection.CreateConnection())
{
connection.Open();
Console.WriteLine("Successfully connected to SQL Server!\n");
string sql = "DELETE FROM actor WHERE actor_id = @actor_id;";
using (SqlCommand command = new SqlCommand(sql, connection))
{
command.Parameters.Add(new SqlParameter("@actor_id", 51));
int rowsAffected = command.ExecuteNonQuery();
if (rowsAffected > 0)
{
Console.WriteLine("Successfully deleted actor with ID 51.");
}
else
{
Console.WriteLine("No actor found with ID 51.");
}
}
}
}
catch (SqlException ex)
{
Console.WriteLine($"Error connecting to database: {ex.Message}");
}
}
}
The appilcation shows that the record has been successfully deleted.
Conclusion
Cloud SQL for SQL Server is a popular choice for users who want secure, reliable SQL Server performance in the cloud while working within Google's ecosystem. We successfully connected to Cloud SQL for SQL Server using dotConnect for SQL Server and demonstrated how to perform essential data operations with SQL Server data hosted on Google Cloud.
From here, you can build new .NET applications, migrate existing ones to the cloud, and explore more advanced data operations.
FAQ
How do you install and activate dotConnect for SQL Server in a .NET project?
Install dotConnect for SQL Server via the EXE installer or by adding the Devart.Data.SqlServer NuGet package to your project, then obtain your personal activation key from your Devart Customer Portal and include it in the connection string via the License Key parameter for a working connection.
How do you create a connection to SQL Server using dotConnect in C#?
Define a connection string that includes host, user ID, password, database, and the License Key value, then create an SqlConnection instance with this string and call Open() for it inside a try-catch block to test and handle connection errors.
How do you enable encryption for secure SQL Server connections with dotConnect?
Use SQL Server Native Network Encryption by configuring encryption in the sqlnet.ora file on both client and server sides. No special parameters are required in the connection string.
Is it possible to connect to SQL Server using Visual Studio Server Explorer with dotConnect?
Yes, add a new Data Connection in Server Explorer, select dotConnect for SQL Server as the provider, enter your credentials, test the connection, and browse SQL Server data directly in Visual Studio.
I'm a technical content writer who loves turning complex topics — think SQL, connectors, and backend chaos–into content that actually makes sense (and maybe even makes you smile). I write for devs, data folks, and curious minds who want less fluff and more clarity. When I'm not wrangling words, you'll find me dancing salsa, or hopping between cities.