© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
Hudrel

✅ Get data from a BDD in C# WPF

Hello, i'm trying to get data from a SQL BDD and put it inside Label.
I'm still having this error (sorry it's in french but you can translate it) :
System.Data.SqlClient.SqlException : 'Une erreur liée au réseau ou spécifique à l'instance s'est produite lors de l'établissement d'une connexion à SQL Server. Le serveur est introuvable ou n'est pas accessible. Vérifiez que le nom de l'instance est correct et que SQL Server est configuré pour autoriser les connexions distantes. (provider: Named Pipes Provider, error: 40 - Impossible d'ouvrir une connexion à SQL Server)'

I've tried to changer the server from 127.0.0.1 to localhost and it's still the same error.
I've tried to open all connection to my SQL BDD still same.
And here is my code :

private void LoadDataFromDatabase()
{
string patchVersion = "";
DateTime date = DateTime.MinValue;
string content = "";

using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();

string query = "SELECT PatchVersion, Date, Content FROM patchnote";
SqlCommand command = new SqlCommand(query, connection);
SqlDataReader reader = command.ExecuteReader();

if (reader.Read())
{
patchVersion = reader.GetString(0);
date = reader.GetDateTime(1);
content = reader.GetString(2);
}

reader.Close();
}

// Mettre à jour les labels dans la fenêtre WPF avec les valeurs récupérées
NewPatchVersion.Content = patchVersion;
NewPatchDate.Content = date.ToString("yyyy-MM-dd");
NewPatchContent.Content = content;
}

Hope it's a beginner issue x)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

❔ Get Data from Table api c#
C#CC# / help
3y ago
❔ Update assembly version from BDD
C#CC# / help
3y ago
c# wpf style
C#CC# / help
11mo ago
✅ data from excel to wpf app
C#CC# / help
4y ago