コード例 #1
0
		/////////////////////////////////////////////////////////////////////////////
		public void GetDataSet(string query, EventHandler requestCompleteHandler)
		{
			m_RequestCompleteHandler = requestCompleteHandler;

			try
			{
#if EXPLICIT
				// It is not really necessary to pass a binding and an endpoint address when creating the service proxy,
				// however, we want to dynamically choose either localhost or the web server
				Uri webServiceUri = new Uri("http://localhost:51698/DBService.svc");
//j				Uri webServiceUri = new Uri("http://facetofacesoftware.com/FutureMoneyWebServices/DBService.svc");
//j				Uri webServiceUri = new Uri("http://www.dreamnit.com/FutureMoneyWebServices/DBService.svc");
				DBServiceClient px = new DBServiceClient(new BasicHttpBinding(), new EndpointAddress(webServiceUri));
#else
				DBServiceClient px = new DBServiceClient();
#endif
				px.GetOleDbDataSetCompleted += GetDataSetCompleted;
				px.GetOleDbDataSetAsync(query);
			}
			catch (Exception e)
			{
				if (m_RequestCompleteHandler != null)
					m_RequestCompleteHandler.Invoke(e.Message, null);
			}
		}
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: nightynight/Demo
 private void GetUser()
 {
     //连接服务端
     EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "/DBService.svc"));
     //建立客户端对象
     DBServiceClient client = new DBServiceClient(new BasicHttpBinding(), address);
     //添加处理事件
     client.GetUserCompleted += new EventHandler<GetUserCompletedEventArgs>(client_GetUserCompleted);
     //传入参数
     client.GetUserAsync(txtUsername.Text, pbPassword.Password);
 }