c#中的Web服务和申请表

时间:2017-03-18 03:59:28

标签: c# vb.net winforms web-services asmx

我在Visual Basic中使用webservice和Windows应用程序我在Web服务中有一个代码,它将数据传递给Web应用程序,我想要做的是在Windows应用程序中将数据显示到textbox

这是我的网络服务代码

   [WebMethod]
   public string searchCom(string compCode)
   {
        string msg = string.Empty;
        SqlConnection conn = new SqlConnection("Data Source=LOCALPC\\SQLEXPRESS1; Initial Catalog=Company;Integrated Security=True;");
        DataTable dt = new DataTable();
        SqlCommand cmd = new SqlCommand("selectPress", conn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        cmd.Parameters.Add("@item", SqlDbType.VarChar).Value = compCode;
        cmd.CommandType = CommandType.StoredProcedure;
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow row in dt.Rows)
            {
                string[] data = new string[3];
                textBox2.Text = Convert.ToString(row["CompanyName"]);
                textBox3.text = Convert.ToDecimal(row["balance"]);
                textBox4.text = Convert.ToDecimal(row["maintBalance"]);
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                button1.Visible = false;
                Back.Visible = true;
            }
       }
       return msg;
   }

这是我的Windows应用程序(VB)中按钮单击的代码

private void button2_Click(object sender, EventArgs e) 
{ 
     string msg = string.Empty; 
     msg = service.searchCom(textBox1.Text); 
}

错误出现在textbox

0 个答案:

没有答案