在C#中为windowes表单调用Web服务 [英] calling web service for windowes form in c#
问题描述
你好先生,
我有一个问题先生,我在其中创建了一个窗口表单,我有很多文本框和组合框,先生,我想为此表单创建Web服务,以将值保存在数据库表中,但是先生,我在intelisense
.我想创建用于在数据库中插入值的方法,并且我想将此方法称为button_click
hello sir ,
I have a problem sir I create a window form in this I have many text box,and combo box, sir I want to create the web service for this form to save the value in database table but sir I create the web method in ".asmx"
form then I not found the text box intelisense
. I want to create the method for insert the the values in database, and I want to call this method to button_click
[WebMethod]
public void saleslead()
{
SqlConnection con = new SqlConnection("Data Source=WHIZ-48\\SQLEXPRESS;Initial Catalog=George;User ID=sa;Password=net@123");
con.Open();
SqlCommand cmd = new SqlCommand("insert into SalesLead values("")",con);
cmd.ExecuteNonQuery();
}
}
先生,在此插入命令中,我们要在文本框中输入供用户运行时使用的值,并将数据保存在数据库表中.
请给我解决方法.
谢谢先生
Arvind kumar singh
[已编辑]代码包装在前置"标签中[/已编辑]
Sir In this insert command we here want to text box for user run time enter the values and save data in database table .
please give me solution.
Thanks sir
Arvind kumar singh
Code is Wrapped in "pre" tags[/Edited]
推荐答案
您需要添加对Web服务代理的引用以便您可以在源代码中调用它.
^ ]可以为您提供帮助.
You need to add a reference to the web service proxy so that you can call it in your source code.
Tihs[^] could help you.
转到 ^ ]来阅读CP文章,该文章重点介绍如何从Win Forms应用程序中使用Web服务.
Go there[^] to read the CP article which focusing how to Consuming Web Services from a Win Forms Application.
这篇关于在C#中为windowes表单调用Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!