Forums - C# Corner

Forum guidelines


  • 1.3k
  • 111
  • 90.1k

c# winforms - binding DataGridView to sdf database

May 28 2012 12:59 PM
I create a small sdf database and put it into project folder.
Trying to bind a DataGridView with that database, I wrote:

using System.Data.SqlClient;
. . .
string connString = "Provider=.NET Framework Data Provider for Microsoft SQL Server Compact 3.5;Data Source=|DataDirectory|\db01.sdf";
  string query = "SELECT * FROM table01";
  SqlDataAdapter dA = new SqlDataAdapter(query, connString);
  SqlCommandBuilder cBuilder = new SqlCommandBuilder(dA);
  DataTable dT = new DataTable();
  BindingSource bS = new BindingSource();
  bS.DataSource = dT;
  dgv01.DataSource = bS;

Error: Keyword not supported: 'provider'.
Could someone explain, what is wrong, please.

Answers (5)

File APIs for .NET
Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!