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.
Loading

VulpesPosted May 28, 2012, 4:10 PM
You'll also need to add a reference to System.Data.SqlServerCe.dll if you haven't added one already.
VulpesPosted May 29, 2012, 9:40 AM
MementoPosted May 29, 2012, 2:10 AM
ThankYou for yourEfforts, it seems your code works...but... but... but...
I must ask someone this question:
Is it possible that databinding is so unnecessary complicated ?
Is it possible that highRangeDevelopers (like Microsoft) cannot produce a simple DataGridView which will hold the data.
If I put some value in a cell, iti is normally to assume that i want that value in that cell, and why all these TimeConsumingAnd Complicated Toys like Connections, DataSet, DataTable, BindingSource, TableAdapters...
Why all these things don't work in the background.
So - drag the DataGridView from the toolbox - and voila - it's redy for entering and hold entered data.
I don't believe that today we have any hardware limitations for such developing approach.
Excuse me if I spend you time, maybe you see all of that -so normally.
Regards.
MementoPosted May 28, 2012, 2:51 PM
A network-related or instance-specific error occurred while establishing a connection to SQL Server... error: 40 - Could not open a connection to SQL Server)
I installed SQL Express during C# express instalation. Or maybe I need SQL Compact Edition ? I have no fully SQL Server. What is your advice?
VulpesPosted May 28, 2012, 2:38 PM