I'm trying to access a SQL Server database, via IP, with this code:
string sqlAsk = "SELECT * " +
"FROM 'account' " +
"WHERE Name =" + accountName + " " +
"AND Password =" + accountPass + " " +
"AND Validation= 1";
string connectionString = "Data Source=[IP], [PORT]; Network Library=DBMSSOCN; Database=[...]; Trusted_Connection=true";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
command = new SqlCommand(sqlAsk, connection);
dataReader = command.ExecuteReader();
while (dataReader.Read())
{
sqlResult = dataReader.GetValue(0).ToString();
}
dataReader.Close();
command.Dispose();
}
I expect this to do either give me all values with the specified accountname and password and then the method at the end returns either true, or false (check if the user exists).
But what I get is this:
IOException: Connection lost
Mono.Data.Tds.Protocol.TdsComm.GetPhysicalPacketHeader () (at connection.Open();)
The Visual Studio Debug (SqlConnection connection
) shows this:
And none of the documented ways of setting a ServerVersion
for the connection string work: Type System Version (on Microsofts .NET doc) leads to "keyword invalid"