I got some difficulties to connect with a database (*.sdf* files).
With Microsoft SQL server 2008, I can open the database and make some SQL request.
So I have tried differents solutions to connect to the database, but I never success.
Have you some solutions or methods to connect to database.
Code: Select all
namespace Neo.ApplicationFramework.Generated
{
using System;
using System.Drawing;
using System.Data;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
public partial class BACKGROUND
{
void Button6_Click(System.Object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=C:/Documents and Settings/fabrice/Mes documents/ECO-ENERGIE/ECO_ENERGIE/Temp/Output/Database.sdf;");
//SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=Database;Integrated Security=SSPI");
try
{
conn.Open();
MessageBox.Show("Database opened....");
// Insert code to process data.
SqlCommand cmd = new SqlCommand("select * from ECO_ENERGIE", conn);
}
catch (Exception ex)
{
MessageBox.Show("Impossible to connect to database");
}
finally
{
conn.Close();
MessageBox.Show("Database closed");
}
}
}
}