Using SQL Server in build

lporras's Avatar

lporras

08 Jul, 2018 11:16 PM

I'm trying to use the sql server instance, but I get the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

This is how the yml looks like:

image: Visual Studio 2017
environment:
  db_test_connstr: Server=(local)\SQL2017;Database=technical_assessment_test;User ID=sa;Password=Password12!
services:
  - mssql2017

  1. Support Staff 1 Posted by Owen McDonnell on 09 Jul, 2018 05:37 AM

    Owen McDonnell's Avatar

    Is this a private repository?

    You've declared an environment variable named db_tst_connstr, but can you explain or link to where in your project you make use of that variable/connection string?

  2. 2 Posted by lporras on 09 Jul, 2018 02:03 PM

    lporras's Avatar

    Yes, it's a private repo.

    I'm using it to poke the test app.config, which is working. The test is using the correct connection string, however when the tests start running, apparently it times out and show the error.

  3. Support Staff 3 Posted by Owen McDonnell on 09 Jul, 2018 07:34 PM

    Owen McDonnell's Avatar

    Sorry, i still don't have a very clear picture of how this variable is being used.
    So you are trying to access this environment variable from the app.config file?

  4. 4 Posted by lporras on 09 Jul, 2018 08:14 PM

    lporras's Avatar

    In the build script I write the value of the variable in the test's app.config file. In ConnectionStrings, so when the data/integration test run, it connects to appveyors db, instead of a local db.

    The tests are using the correct ConnectionString as I am writing it in console:

    Running tests against Server=(local)\SQL2017;Database=technical_assessment_test;User ID=sa;Password=Password12!
    
    The problem is when the test try to connects to the database, as the error is shown:
    System.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
    
  5. Support Staff 5 Posted by Owen McDonnell on 10 Jul, 2018 01:02 AM

    Owen McDonnell's Avatar

    Can you try adding the following section to your appveyor.yml file

    
    before_test:
      ps: |
            $sqlConnection = New-Object System.Data.SqlClient.SqlConnection "Server=(local)\SQL2017;Database=technical_assessment_test;User ID=sa;Password=Password12!";
            $sqlConnection.Open();
    
    and see if it throws an error.

    Also, try printing the content of the app.config file before and after your build script writes to it just to make sure its writing as expected.

  6. Ilya Finkelshteyn closed this discussion on 09 Sep, 2018 09:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

23 Oct, 2018 08:45 PM
23 Oct, 2018 07:48 PM
23 Oct, 2018 06:50 PM
23 Oct, 2018 06:06 PM
23 Oct, 2018 05:51 PM