我看了一遍,发现没有解决方案。我不确定导致问题的是什么,如果有人能够提供帮助,我将非常感激。我还在努力学习这门语言。
private void SignInButton_MouseDown(object sender, MouseButtonEventArgs e)
{
/// Check Username and password from text box
string username = UserName.Text;
string password = Password.Text;
SqlConnection myConnection = new SqlConnection(@"Data Source=46.4.90.149\MyInstance,3306;Network Library=DBMSSOCN;Initial Catalog=XXXXXX;User ID=XXXXX;Password=XXXXXX");
try
{
if (myConnection.State == ConnectionState.Closed)
myConnection.Open();
SqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandText = "SELECT Username, Password FROM PlayerInfo WHERE Username =@Username AND Password =@Password";
myCommand.Parameters.AddWithValue("@Username", username);
myCommand.Parameters.AddWithValue("@Password", password);
int count = Convert.ToInt32(myCommand.ExecuteScalar());
if(count==1)
{
MessageBox.Show("HELLO YOU'RE LOGGED IN");
myConnection.Close();
}
else
{
MessageBox.Show("Can't find account");
myConnection.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
myConnection.Close();
}
}
}
}
我已经尝试了多种解决方案,然后才会抛出connection string is invalid
。我设法解决了这个问题,现在我得到了internal error connection error 18.