0

I am encountering an error while running C# application that containing SQL Server Database, the problem is that the moment i press start button my database connection failed, and a red cross appears near the database icon "as illustrated in the posted image", and this cross disappeared when i rebuild the solution. enter image description here can any one help me

 SqlConnection Con = new SqlConnection("Server=local;Database=Books;integrated Security=True");
        SqlDataAdapter Da;
        DataTable Dt = new DataTable();
        Da = new SqlDataAdapter(" Select * From Sadera", Con);
        Da.Fill(Dt);
        saderaDataGridView.DataSource = Dt;
Bengi Besçeli
  • 3,638
  • 12
  • 53
  • 87
Hesham
  • 41
  • 6
  • Can you edit the post with the connection string you're using ? – Antoine Thiry Feb 25 '17 at 16:06
  • See also http://stackoverflow.com/questions/15631602/how-to-set-sql-server-connection-string – Tony Feb 25 '17 at 16:20
  • I think you should check your connectionstring. – Bengi Besçeli Feb 25 '17 at 16:45
  • 1
    You haven't told us what database you're using, but my guess would be to change your connection string to `Data Source=|DataDirectory|Books.sdf;integrated Security=True` and ensure the Copy To Output Directory property of Books.sdf is "copy if newer". – Dour High Arch Feb 25 '17 at 18:02

0 Answers0