我正在嘗試將我的Silverlight應用程序連接到SQL Server 2005以用於登錄目的。我對Silverlight完全陌生,並希望在Silverlight中構建自己的網站。請建議有用的地點進行放肆。提前Thanx。如何將我的silverlight應用程序連接到SQL Server 2005
回答
您必須使用Web服務示例WCF。 1)將WCF添加到您的項目中。
//This is your interface Class.
namespace SilverlightApplication1.Web
{
[ServiceContract]
public interface IService1
{
[OperationContract]
bool UserLogin(string email, string password);
}
}
//This is your service code behind class
namespace SilverlightApplication1.Web
{
public class Service1 : IService1
{
public bool UserLogin(string email,string password)
{
// Your logic here to verify user name and password
}
}
}
//After creating the service. Add a reference to your application.**
2)服務引用添加到您的Silverlight應用程序。 右鍵單擊您的項目,選擇Web引用選項並將該服務添加到您的項目中。現在,如果您的表單上有一個按鈕控件,它會將數據提交給您的wcf服務。在其單擊事件中添加以下代碼。
Service1Client proxy ;
private void button1_Click(object sender, RoutedEventArgs e)
{
proxy.UserLogin += new EventHandler<InsertDataCompletedEventArgs>(proxy_UserLogin);
proxy.UserLogin(txtEmail.Text, "Password");
}
void proxy_UserLogin(object sender, InsertDataCompletedEventArgs e)
{
if (e.Result == true)
{
lblMesg.Content = "User Login successfully";
}
else
{
lblMesg.Content = "User record not found";
}
}
在按鈕單擊事件調用該服務。
woa,你真的應該在你的標記:) – 2012-07-16 06:15:35
@AndreasNiedermair更新。 :) – 2012-07-16 06:18:52
真棒!....... – 2012-07-16 06:21:18
如果你想要登錄,您可以創建一個Silverlight業務應用程序項目中的SQL Server連接。它內置了用戶登錄。這樣,您可以專注於Silverlight應用程序的其他功能。
- 1. 如何ASP.NET應用程序連接到遠程SQL Server 2005
- 2. 如何將我的Silverlight應用程序連接到WCF服務?
- 3. ASP.net應用程序無法連接到SQL Server 2005數據庫
- 4. 從C#應用程序問題連接到SQL Server 2005
- 5. 如何從我的android應用程序連接到sql server?
- 6. 如何我的web應用程序連接到SQL Server/SQL Server Express的
- 7. SQL Server 2005遠程連接
- 8. BIRT:如何連接到SQL Server 2005
- 9. 連接到SQL Server 2005
- 10. Ruby連接到SQL Server 2005
- 11. 如何將一個asp.net web應用程序連接到SQL Server
- 12. 如何通過jbdc將Android應用程序連接到SQL Server?
- 13. 如何將SQL Server 2008連接到WPF應用程序
- 14. 將SQL Server 2005連接到Access 2.0
- 15. 將SQL Server 2005連接到Eclipse
- 16. 無法連接到遠程SQL Server 2005
- 17. 將應用程序從另一個網段連接到SQL Server
- 18. 如何將SQL文件連接到我的Bluej應用程序?
- 19. 如何從.NET應用程序連接到SQL Server Compact?
- 20. 使用PHP連接到SQL Server 2005
- 21. 多個SQL Server連接到我的ASP.NET Web應用程序
- 22. 我的Winforms應用程序沒有連接到SQL Server 2000?
- 23. 獲取VMS的驅動程序連接到SQL Server 2005
- 24. 從Visual Studio到SQL Server 2005的連接
- 25. 應用程序如何連接到SQL Server數據庫?
- 26. 如何從ios應用程序連接到SQL Server數據庫?
- 27. 如何防止其他應用程序連接到SQL Server?
- 28. 當連接到SQL Server 2005時,SQL Server不允許遠程連接
- 29. 如何使用C#中的IP地址將應用程序連接到SQL Server?
- 30. 將LINQPad連接到遠程SQL Server
建設性的批評:這個問題太泛泛,無法得到有用的答案。基本原則是Silverlight無法直接連接到數據庫,因此您需要通過其他方式代理請求。一個非常通用的起點:http://www.dotnetcurry.com/ShowArticle.aspx?ID = 624 – 2012-07-16 15:40:03