Results 1 to 8 of 8

Thread: VB.NET app deployment

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    58

    VB.NET app deployment

    I have an VB.NET app that connects to a local SQL SERVER EXPRESS database

    On the computer I developed the application everything works ok but when I try to deploy the application on another computer with SQL SERVER EXPRESS installed an error message appears : << under the default settings SQL SERVER does not allow remote connections. (provider :SQL Network Interfaces, error 26 : Error Locating Server/Instance Specified) >>

    Is it the connection string that is bad or the fact the on my machine I have an SQL SERVER EXPRESS instance named COMPUTER\MYNAME and on the deployment machine I have another instance name

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: VB.NET app deployment

    If using SQL Express then ComputerName\SQLExpress (this is a named instance).
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    58

    Re: VB.NET app deployment

    that's exactly my problem ... ComputerName is different for every computer I install the application ... it must be an environment variable that emulates the ComputerName in VB.NET

    For example if my computer has ComputerName='MAKKO' and the computer I must install the application has the ComputerName='SOMETHINGELSE' on my computer the environment variable has to be MAKKO and on other computer the environment variable should be SOMETHINGELSE

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB.NET app deployment

    You shouldn't be using the machine name at all. This is from www.connectionstrings.com:
    Data Source=.\SQLExpress;Integrated Security=true;AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
    That is also what VS does by default when you add a SQL Server database to your project.

    You can also use "(local)" instead of the dot.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    58

    Re: VB.NET app deployment

    thank you jmcilhinney ...

    So i should use Data Source=.\SQLExpress; if I install an SQLExpress named instance

    If i decide to install the default instance I would use Data Source=.; or
    Data Source=(local); ???

    And another question regarding SQL SERVER instalation ... At the 4th step of instalation USE THE BUILT IN SYSTEM ACCOUNT ... Should I choose Local System ? or Local Service / Network
    Last edited by makko; Apr 1st, 2008 at 05:30 AM.

  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    58

    Re: VB.NET app deployment

    If I enter myself the following code :

    AppDomain.CurrentDomain.SetData("DataDirectory", "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data")
    Dim sqlconn As String = "Server=.;AttachDbFilename=|DataDirectory|test.mdf;Database=test;Trusted_Connection=Yes;"

    string strSQL = “select * from table1”;
    SqlDataAdapter dataAdapter = new SqlDataAdapter(strSQL, strCon);
    SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
    DataTable table = new DataTable();
    table.Locale = System.Globalization.CultureInfo.InvariantCulture;
    dataAdapter.Fill(table);
    dbBindSource.DataSource = table;
    dbGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
    dbGridView.ReadOnly = true;
    dbGridView.DataSource = dbBindSource;

    I get the result I want ...

    But sometime I need to bind the tables to datagridview not from code but from designer ... And the designer creates automaticly an connection string like "Data Source=MYCOMPUTERNAME;Initial Catalog=test;Integrated Security=True"

    What can I do so the designer creates an connection string like "Server=.;AttachDbFilename=|DataDirectory|test.mdf;Database=test;Trusted_Connection=Yes;"


    Thx

  7. #7
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: VB.NET app deployment

    SQLExpress is always a named instance. You don't have a choice in that.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    58

    Re: VB.NET app deployment

    I resolved the problem ...

    At the SqlServerExpress instalation :

    - selected the 'default' instance
    - selected the 'local system'

    In the code if I want to connect without designer I create myself the connection string like "Server=.;AttachDbFilename=|DataDirectory|test.mdf;Database=test;Trusted_Connection=Yes;"

    If I want to connect with designer the connection strings will look like "Data Source=MYCOMPUTERNAME;Initial Catalog=test;Integrated Security=True"
    and I will replace mannualy the MYCOMPUTERNAME string with '.' character

    For me that worked very well

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width