使用文本框和Web服务将信息保存到数据库中

时间:2014-03-27 18:44:24

标签: c# sql web-services silverlight webmethod

好的我可以在我的按钮单击中单独使用SaveScore();方法将分数保存到列数中的数据库,但我也尝试让用户在文本框中输入名称{{1}并将其插入到数据库的Name列中。

如果我只有inputname.text按钮单击它可以工作(将分数插入计数列),那么它不会插入inputname.text

但是inputname.text我无法将字符串插入Name列

以下是C#代码

SaveScore();

网络服务和查询

 private void SaveScore()
    {
        ServiceReference1.WebService1SoapClient service = new ServiceReference1.WebService1SoapClient();
        service.SaveScoreCompleted += new EventHandler<ServiceReference1.SaveScoreCompletedEventArgs>(SaveScoreCompleted);
        service.SaveScoreAsync(PopBalloonCount);
    }

 void SaveScoreCompleted(object sender, ServiceReference1.SaveScoreCompletedEventArgs e)
  {
      if (e.Error == null)
          if (e.Result == true)
              Console.WriteLine(e.Result);
          //  showsave.Text = "saved succesfully";   
          else
              showsave.Text = " Not saved ";        
   }

  private void savestuff_Click(object sender, RoutedEventArgs e)
    {
       ServiceReference1.WebService1SoapClient serv = new ServiceReference1.WebService1SoapClient();
       serv.SaveScoreCompleted += new EventHandler<ServiceReference1.
       SaveScoreCompletedEventArgs>(SaveScoreCompleted);
       serv.SaveScoreAsync(Int32.Parse(nameinput.Text)); // need to save nameinput.text string into Name column 
        SaveScore(); // where score in to count column
    }

0 个答案:

没有答案