数据的访问
SQL CE 数据的访问
l 与桌面应用程序一致的模型
Ø SQLCEDataAdapter = SqlDataAdapter
Ø SQLCECommand = SqlCommand
Dim ceConn as new SqlCEConnection( _
"Data Source=My Documents\DemoDB.sdf;password=‘pass’)
Dim ceComm as new SqlCECommand( _
"select count(*) from authors", ceConn)
ceConn.Open() MessageBox.Show(ceComm.ExecuteScalar().ToString())
ceConn.Close()

| Retrieving data from a CE database is exactly the same as retrieving data from a SQL Server. You simply use the equivalent types in the System.Data.SqlServerCe namespace like SqlCeDataAdapter and SqlCeCommand. This example connects to the DemoDB database and displays the number of authors in a message box. SqlCeCommands support parameterized queries, but not named parameters. You must use question marks in your queries as placeholders and then add SqlCeParameter objects to your command in order.