المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Connection to SQL Server on the remote computer



C# Programming
01-21-2010, 03:40 PM
Hi!

I am trying to deploy the application on Windows CE 6.0 platform. However, when it comes to connection to SQL Server on my laptop it "thinks" for a while and I receive the following error:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Windows.Forms.dll

Additional information: SqlException


I tried to find out the root of the problem and found out that my code

static string connectionString = "Data Source=192.168.2.132; Initial Catalog=MDetectorDatabase; Integrated Security=true";

private void SubmitButton_Click(object sender, EventArgs e)
{
string login = this.loginTextBox.Text;
string passw = this.passwTextBox.Text;
string user = "";

SqlConnection loginConnection = new SqlConnection(connectionString);
string loginquery = "SELECT * FROM Doctors Where UserName='" + login + "';";
SqlCommand loginCommand = new SqlCommand(loginquery, loginConnection);

loginConnection.Open();

SqlDataReader loginReader = loginCommand.ExecuteReader();
...
}
broke on loginConnection.Open(); line showing the problem 'loginConnection.ServerVersion' threw an exception of type System.InvalidOperationException'

Does anybody know how to fix this problem?