Note that there are some explanatory texts on larger screens.

plurals
  1. POEnable remote connections to sql express with a script
    primarykey
    data
    text
    <p>I am deploying an application with sql server express 2008. In the prerequisites section of my application I have included:</p> <p><img src="https://i.stack.imgur.com/81gSv.gif" alt="enter image description here"></p> <p>As a result when a user installs my application it will install sql express as well.</p> <p>Then I will be able to connect to that database engine as:</p> <pre><code> try { // database should be in the same network SqlConnection conn = new SqlConnection(@"Data Source=.\sqlexpress; Integrated Security=True"); conn.Open(); MessageBox.Show("Connection succesfull"); } catch { MessageBox.Show("Unable to connect"); } </code></pre> <hr> <p>Now when I install a different application(client version) I will like to be able to connect to that database engine. I managed to connect to it by doing something like:</p> <pre><code> try { SqlConnection conn = new SqlConnection(@"Data Source=192.168.0.120\sqlexpress,22559; USER=sa; PASSWORD=*********"); conn.Open(); MessageBox.Show("Connection succesfull"); } catch { MessageBox.Show("Unable to connect"); } </code></pre> <p>In order for that code to work I had to do the following:</p> <p><img src="https://i.stack.imgur.com/nUfgc.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/WqZZr.png" alt="enter image description here"></p> <hr> <h2>So my question is:</h2> <p>How could I configure this with code? When I deploy my application I want my application to install sql express like it does but I also whant to enable tcp/IP connections, enable some ports and lastly create a password for the account "SA" because I am not able to connect to the database remotly if the sa account does not have a password. </p> <p>Or maybe I am asking to much and I am doing the wrong thing. perhaps I should do all this just for the database that I am planing on deploying not the database engine. whatever is easier. I have had a hard time deploying this maybe it will be eassier to deoploy a local database along with a wcf service in order to create CRUD operations on the local database remotely.</p> <h2>EIDT</h2> <p>I found this 3 links that claim on doing something similar and I still cannot make it work.</p> <p>1) <a href="http://support.microsoft.com/kb/839980" rel="nofollow noreferrer">http://support.microsoft.com/kb/839980</a></p> <p>2) <a href="http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/c7d3c3af-2b1e-4273-afe9-0669dcb7bd02/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/c7d3c3af-2b1e-4273-afe9-0669dcb7bd02/</a></p> <p>3) <a href="http://www.sql-questions.com/microsoft/SQL-Server/34211977/can-not-connect-to-sql-2008-express-on-same-lan.aspx" rel="nofollow noreferrer">http://www.sql-questions.com/microsoft/SQL-Server/34211977/can-not-connect-to-sql-2008-express-on-same-lan.aspx</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload