|
Forums » .NET » Silverlight »
|
Insertion of record from sl to db |
Posted Date: 17 Jun 2010 Posted By:: Harikrishna Member Level: Gold Member Rank: 393 Points: 1
Responses:
2
|
hi frnz, i have a query. i want to insert record ie emp details into db using silverlights. i designed 4 textbox's in sl page.xaml and if user clicks on submit button details must b send to d db. i tried wcf etc but m unable to create object for wcf class in page.xaml.cs
plz let me knw d sol.
thanks in advance
4m krishna
|
Responses
|
#520240 Author: Nishikant Member Level: Gold Member Rank: 94 Date: 23/Jun/2010 Rating:  Points: 2 | Hi,
Did you add service reference to your WCF service in your SL app?
Regards, Nishikant K
"All things are difficult before they are easy" My Blog on Silverlight
| #531423 Author: Harikrishna Member Level: Gold Member Rank: 393 Date: 26/Jul/2010 Rating:  Points: 2 | This is d sol Add WCF Service and implement method public bool Insert(string Name, double salary, int deptno, string address) { try { DataClassesDataContext db = new DataClassesDataContext(); Emp obj = new Emp(); obj.Name = Name; obj.Salary = salary; obj.deptno = deptno; obj.address = address; db.Emps.InsertOnSubmit(obj); db.SubmitChanges(); return true; } catch { return false; } } Add wservice reference to SL project and in page.xaml private void btnSubmit_Click(object sender, RoutedEventArgs e) {
ServiceReference1.ServiceClient sc = new ServiceReference1.ServiceClient(); string Name = txtName.Text; double Sal = Convert.ToDouble(txtSal.Text); int deptno = Convert.ToInt32(txtdeptno.Text); string Address = txtAddr.Text; sc.InsertAsync(Name, Sal, deptno, Address); sc.InsertCompleted += new EventHandler<ServiceReference1.InsertCompletedEventArgs>(sc_InsertCompleted); }
From Hari
|
|
| Post Reply |
|
|
|
 | | This thread is locked for new responses. Please post your comments and questions as a separate thread. If required, refer to the URL of this page in your new post. |
|
|
|
|
 Follow us on Twitter: https://twitter.com/dotnetspider
|
|