I am attempting to connect to Mssql server that is not local. I am using SQLx
and am attempting to connect using the following:
use sqlx::mssql::MssqlPool;
#[tokio::main]
async fn main() -> Result<(), sqlx::Error>
{
let pool = MssqlPool::connect("mssql://server/db?trusted_connection=yes&driver=ODBC+Driver+17+for+SQL+Server")
.await?;
let result = sqlx::query("select top 100 * from db.dbo.tbl")
.execute(&pool)
.await?;
println!("{:?}", result);
Ok(())
}
I omitted server and db names for obvious reasons. Everything builds fine, however I believe my connection string is incorrect. All examples from other questions I have seen require a user/pass, but given this is on company premises, I want to connect in a similar fashion as how I would in Python using pyodbc
and the SQL Server driver installed on my machine.
The error when trying to run:
Error: Database(MssqlDatabaseError { message: "Login failed for user 'sa'.", number: 18456, state: 1, class: 14, server: "server", procedure: "", line: 1 })