So i m using this code for my sql connection to connect to local server :
public void ConnectToSql(string ServerName, string UserName, string Password)
        {
            string strConnection = "server=" + tbServer + ";uid=" + tbUser + "; pwd=" + tbPwd;
            SqlCon = new System.Data.SqlClient.SqlConnection();
            SqlCom = new System.Data.SqlClient.SqlCommand();
            SqlCon.ConnectionString = strConnection;
            SqlCom.CommandType = System.Data.CommandType.Text;
            SqlCom.Connection = SqlCon;
            {
                try
                {
                    SqlCon.Open();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to connect to data source");
                }
            }
I call it like this :
 private void Button_Click(object sender, RoutedEventArgs e)
        {
            ConnectToSql(tbServer.Text, tbUser.Text, tbPwd.Text);
        }
In windows form works perfect but when i try it in WPF gues what , cant connect to local server. Any sugestions ??