Tested by VS2013 + sql2012 + win8.1 Author: yijian
1. Create the sliverlight project testWCFsql;
2. Right-click the web Project to add a new item> class and name it ClassDBserver. modify the code:
DataSet DBselect(= (SqlConnection cnn = (SqlTransaction trans = (SqlCommand cmd = = (DataSet ds = (SqlDataAdapter da =
3. Right-click testWCFsql. Add the new item "Silverlight-enabled WCF Service" in the web project and name it ServiceWCF;
4. Modify
Is
List<ClassEmployee>= ClassDBserver.DBselect(<ClassEmployee> userList = List<ClassEmployee>(); (DataRow dr ds.Tables[= ClassEmployee(); user.ID = ()dr[= ()dr[= ()dr[
5. generate it;
6. Right-click the testWCFsql project on the client and add a service reference. The default value is ServiceReference1. OK;
7. Double-click the page file MainPage. xaml. cs, drag the DataGrid control from the toolbox, and name it datagrid1;
8. Modify the background code:
= += EventHandler<ServiceReference1.getDataCompletedEventArgs > myGetDataCompleted(<ServiceReference1.ServiceWCFClassEmployee> users ==
9. This step is optional. Double-click Weg. config to modify the settings.
<configuration> <system.we
Insert
<appSettings> <add key= value=/> </appSettings> <connectionStrings> <add name= connectionString= providerName=/> </connectionStrings>
Modify the connection string in ClassDBserver. cs to read from the configuration file.
10. Now, just run it !!