Silverlight, connecting service.cs and XAML.cs for database -


i've found sample showing how connect sql server (a local mdf), uses databinding, how can use sql in normal way (insert, select, update, delete..., sqldatareader, without binding), think sql staff should performed in service.cs, how can use sql xaml.cs? here service code:

and here service.cs:

public class servicecustomer : iservicecustomer {     public clscustomer getcustomer(int intcustomer)     {         sqlconnection objconnection = new sqlconnection();         dataset objdataset = new dataset();         sqldataadapter objadapater = new sqldataadapter();         sqlcommand objcommand = new sqlcommand("select * customer customerid=" + intcustomer.tostring());         objconnection.connectionstring = system.configuration.configurationmanager.connectionstrings["connstr"].tostring();         objconnection.open();         objcommand.connection = objconnection;         objadapater.selectcommand = objcommand;         objadapater.fill(objdataset);         clscustomer objcustomer = new clscustomer();         objcustomer.customercode = objdataset.tables[0].rows[0][0].tostring();         objcustomer.customer = objdataset.tables[0].rows[0][1].tostring();         objconnection.close();         return objcustomer;     } } 

and page.xaml.cs:

public page()     {         initializecomponent();         servicecustomerclient obj = new servicecustomerclient();         obj.getcustomercompleted += new eventhandler<getcustomercompletedeventargs>(displayresults);         obj.getcustomerasync(1);     }     void displayresults(object sender, getcustomercompletedeventargs e)     {         layoutroot.datacontext = e.result;      } 

how can insert value dayabase right page.xaml.cs? how can make connection between service , xaml objects , functions?

thanks

the page.xaml.cs file not autogenerated in standard silverlight project (beyond it's initial creation via template), changes make class persist.

if current project autogen of xaml classes can use partial class feature of c# partial classes in c# guide add class without worrying autogen remove additions.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -