Ouvrir fichier mdf en C#
Résolu
sympatiqueCCM
Messages postés
363
Date d'inscription
Statut
Membre
Dernière intervention
-
sympatiqueCCM Messages postés 363 Date d'inscription Statut Membre Dernière intervention -
sympatiqueCCM Messages postés 363 Date d'inscription Statut Membre Dernière intervention -
A voir également:
- Lire fichier mdf
- Lire le coran en français pdf - Télécharger - Histoire & Religion
- Lire fichier epub - Guide
- Fichier bin - Guide
- Fichier rar - Guide
- Fichier .dat - Guide
5 réponses
Et bien si te montrer que d’autres ont développé et mis à disposition de tous 2 codes dédiés à cette base de données ne t’aide pas, alors je ne peux rien pour toi, et probablement que personne ne pourra rien pour toi....
Bonjour,
J'ai trouvé ce lien sur internet : https://askcodez.com/comment-me-connecter-a-un-fichier-de-base-de-donnees-mdf.html
J'éspére que tu vas arrivé à trouvé la solution... Dis moi si tu à réussi ou pas
Cordialement
J'ai trouvé ce lien sur internet : https://askcodez.com/comment-me-connecter-a-un-fichier-de-base-de-donnees-mdf.html
J'éspére que tu vas arrivé à trouvé la solution... Dis moi si tu à réussi ou pas
Cordialement
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Au niveau de la Persistance des données avec SQLite, si ça peut aider.
using System;
using System.IO;
using System.Data.SQLite;
namespace CreerBDD
{
class Program
{
static void Main(string[] args)
{
string bddpath = "c:\\data\\bdd.sqlite";
if (!File.Exists(bddpath)) CreateBDD();
AddData("Dupont", "Marcel");
AddData("Gates", "Bill");
AddData("Jobs", "Steeve");
//creation de la bdd
void CreateBDD()
{
SQLiteConnection.CreateFile(bddpath);
SQLiteConnection con = new SQLiteConnection("Data Source = c:\\data\\bdd.sqlite;Version=3;");
con.Open();
string sql = "create table clients (nom varchar (20), prenom varchar(20))";
SQLiteCommand command = new SQLiteCommand(sql, con);
command.ExecuteNonQuery();
con.Close();
}
//Ajouter des données dans la table clients
void AddData(string n, string p)
{
SQLiteConnection con = new SQLiteConnection("Data Source = c:\\data\\bdd.sqlite;Version=3;");
con.Open();
string sql = "INSERT INTO clients(nom, prenom) VALUES ('" + n + "', '" + p + "')";
SQLiteCommand comand = new SQLiteCommand(sql, con);
comand.ExecuteNonQuery();
con.Close();
}
//Lire la Table
SQLiteConnection con = new SQLiteConnection("Data Source = c:\\data\\bdd.sqlite;Version=3;");
con.Open();
string sql = "SELECT * FROM clients";
SQLiteCommand command = new SQLiteCommand(sql, con);
SQLiteDataReader dr = command.ExecuteReader();
while(dr.Read ())
{
Console.Write("Nom : " + dr.GetString(0));
Console.WriteLine(" Prenom : " + dr.GetString(1));
}
}
}
}
using System;
using System.IO;
using System.Data.SQLite;
namespace CreerBDD
{
class Program
{
static void Main(string[] args)
{
string bddpath = "c:\\data\\bdd.sqlite";
if (!File.Exists(bddpath)) CreateBDD();
AddData("Dupont", "Marcel");
AddData("Gates", "Bill");
AddData("Jobs", "Steeve");
//creation de la bdd
void CreateBDD()
{
SQLiteConnection.CreateFile(bddpath);
SQLiteConnection con = new SQLiteConnection("Data Source = c:\\data\\bdd.sqlite;Version=3;");
con.Open();
string sql = "create table clients (nom varchar (20), prenom varchar(20))";
SQLiteCommand command = new SQLiteCommand(sql, con);
command.ExecuteNonQuery();
con.Close();
}
//Ajouter des données dans la table clients
void AddData(string n, string p)
{
SQLiteConnection con = new SQLiteConnection("Data Source = c:\\data\\bdd.sqlite;Version=3;");
con.Open();
string sql = "INSERT INTO clients(nom, prenom) VALUES ('" + n + "', '" + p + "')";
SQLiteCommand comand = new SQLiteCommand(sql, con);
comand.ExecuteNonQuery();
con.Close();
}
//Lire la Table
SQLiteConnection con = new SQLiteConnection("Data Source = c:\\data\\bdd.sqlite;Version=3;");
con.Open();
string sql = "SELECT * FROM clients";
SQLiteCommand command = new SQLiteCommand(sql, con);
SQLiteDataReader dr = command.ExecuteReader();
while(dr.Read ())
{
Console.Write("Nom : " + dr.GetString(0));
Console.WriteLine(" Prenom : " + dr.GetString(1));
}
}
}
}