Hey, I am trying to create a login page that checks the username and password with the database on the server. The server is located in a different country.
This is the code I have so far:
#region Building the connection string
string Server = "XX.XXX.XX.XX, XXXX";
string Username = "_Username_";
string Password = "_Password_";
string Database = "_Database_";
string ConnectionString = "Data Source=" + Server + ";";
ConnectionString += "User ID=" + Username + ";";
ConnectionString += "Password=" + Password + ";";
ConnectionString += "Initial Catalog=" + Database;
#endregion
SqlConnection SQLConnection = new SqlConnection();
try
{
SQLConnection.ConnectionString = ConnectionString;
SQLConnection.Open();
// You can get the server version
// SQLConnection.ServerVersion
}
catch (Exception Ex)
{
// Try to close the connection
if (SQLConnection != null)
SQLConnection.Dispose();
// Create a (useful) error message
string ErrorMessage = "A error occurred while trying to connect to the server.";
ErrorMessage += Environment.NewLine;
ErrorMessage += Environment.NewLine;
ErrorMessage += Ex.Message;
// Show error message (this = the parent Form object)
MessageBox.Show(this, ErrorMessage, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// Stop here
return;
}
I am getting the error message:
Non-negative number required.
Parameter name: count
I have accepted wildcards on my server and I have no idea what that error means?
Any help would be appreciated,
Thanks.