Memento

Memento

  • NA
  • 111
  • 133.5k

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;
. . .
Form1_Load:
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();
  dA.Fill(dT);
  BindingSource bS = new BindingSource();
  bS.DataSource = dT;
  dgv01.DataSource = bS;

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

Answers (5)