-2

I'm trying to run this sample codes - https://marcominerva.wordpress.com/2017/10/25/using-sqlclient-apis-and-dapper-with-fall-creators-update-sdk/

I imported their database as well but not sure why it keep appearing System.Data.SqlClient.SqlException. enter image description here

I already clean and build my solution and it doesn't work still

public sealed partial class MainPage : Page
{
    // public string ConnectionString { get; set; } = 
    private string connectionString =@"Data Source=LAPTOP-IQQCR1C1;Initial Catalog = DatabaseDemo; Persist Security Info=True;User ID = xxxx Password=xxxxxxx";

    //public string ConnectionString { get => connectionString; set => connectionString = value; }

    public MainPage()
    {
        this.InitializeComponent();
    }

    protected override async void OnNavigatedTo(NavigationEventArgs e)
    {
        var cities = await GetCitiesAsync(); //THIS LINE OF CODES GIVE THE SYSTEM.DATA.SQLCLIENT.SQLEXCEPTION

        CitiesComboBox.ItemsSource = cities;
        CitiesComboBox.SelectedIndex = 0;

        base.OnNavigatedTo(e);
    }

It still runs. But can't read the data for the dropdown and when searched, cannot read images from database.

Output: sample

What I want: sample

  • Are you able to connect to your database using Sql Server Management Studio and applying the supplied connnection string info? – Steve Jan 18 '19 at 10:14
  • Can you connect to the local instance (LAPTOP-IQQCR1C1) you created using your machine on which you are running this code? – Gaurav Jan 18 '19 at 10:17
  • 1
    Probably best not to post credentials like *User ID = alish; Password=polylife16;* in questions. – ta.speot.is Jan 18 '19 at 11:48
  • Can you connect to the server with SQL Server Management Studio? Are you using the *same* address as the one you used in SSMS? – Panagiotis Kanavos Jan 18 '19 at 11:53

1 Answers1

0

The SqlException with the error 40 means, that you can't connect to your SQL Server.

It seems that you have a wrong configuration on your server or the server is offline.

  1. check if the service "SQL Server (INSTANCENAME)" is running on your machine
  2. check in the Configuration Manager (SQL Server) if TCP/IP is enabled
  3. check in the SQL Management Studio if the Server properties if remote connections are enabled.
  4. if the SQL Server is not on your local machine, make sure the ports for communication are opened

Here you can find a detailed description on how to do the steps above.

bene_rawr
  • 119
  • 1
  • 10