locked
Problem when create mobile application to access SQL Server from emulator RRS feed

  • Question

  • When I tried the following code, i got this exception, "Login failed. The login is from an untrusted domain and cannot be used with Windows authentucation."

    I used the same connection string in my windows application but it did not work on windows mobile application.
    Has anyone here can suggest the way for solving it?,because my work struck this area very long time.

    private void button1_Click(object sender, EventArgs e)
            {
                string sConnection = "Server =192.168.1.3,1433;" + "Database =CSCRM;Integrated Security=SSPI"; 
    string sSQL = "SELECT [EmployeeID],[Username],[Password],[RightForUsed] FROM [CSCRM].[dbo].[MasAuthenEmp] Where [Username] = '" + username.Text + "'"; SqlCommand comm = new SqlCommand(sSQL, new SqlConnection(sConnection)); SqlDataReader dr = null; try { comm.Connection.Open(); dr = comm.ExecuteReader(); while (dr.Read()) { MessageBox.Show(dr[0].ToString()); } } catch (SqlException ex) { MessageBox.Show(ex.Message); return; } dr.Close(); comm.Connection.Close(); }
    I already check the connectivity of emulator. It could access the internet from emulator.

    Thank you everyone in advance

    Sincerely

    Zenoni
    Tuesday, December 29, 2009 7:15 PM

All replies

  • Unlike desktop, there's no login procedure on device. So there are no default credentials to pass to the server. Thus you have to provide credentials in the connection string.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, December 29, 2009 7:22 PM
  • Unlike desktop, there's no login procedure on device. So there are no default credentials to pass to the server. Thus you have to provide credentials in the connection string.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thank Tumanov for the answer,

    Would you please give the example of credentials in the connection string for me?
    As I think I have to specify
    String connectionString;
        connectionString =  "data source=myserver";
        connectionString += ";initial catalog=northwind";
        connectionString += ";user id=" + userid;
                connectionString += ";password=" + password;
    
    something like this or not.

    Zenoni
    Tuesday, December 29, 2009 7:36 PM
  • Yes, that should do.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, December 29, 2009 8:59 PM
  • Dear Tumanov

    My error still occurs the same.

    Zenoni
    Wednesday, December 30, 2009 9:37 AM