本文介绍了如何使用Windows应用程序使用来自sqlserver的数据填充Web表单.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经开发了一个Windows应用程序,在其中我必须使用本地数据库中的值填充外部Web表单.请帮助我. 谢谢&问候, martin.
Hi , I have developed a windows application where in I have to fill a external webform with a values from the local database . please help me on this . thanks & Regards, martin.
推荐答案用于网络活动的自动化工具 [ ^ ]可能会为您提供帮助. 您可以在此处 [ ^ ]. Automation tool for web activities[^] may help you. You can convert it to c# here[^].
嗨 使用SQL Server存储过程中的DataReader并将数据加载到DataTable中,并使用此DataTable填充GridView.这有道理吗?还要导入System.Data.SqlClient命名空间. 例如: 这需要进入页面代码的顶部(头部上方): 受保护的void Page_Load(对象发送者,EventArgs e) { if(IsPostBack == false){ BindGrid(); } } 私有void BindGrid() { SqlConnection objConn =新的SqlConnection("Server = YourServer; UID = user; PWD = pass; Database = YourDatabase"); SqlCommand objCmd =新的SqlCommand("GetAllEmployees",objConn); objCmd.CommandType = CommandType.StoredProcedure; objConn.Open(); SqlDataReader DR = objCmd.ExecuteReader(); Employees.DataSource = DR; Employees.DataBind(); DR.Close(); DR =空; objCmd.Dispose(); objCmd = null; objConn.Close(); objConn = null; } 然后以您体内的形式使用它进行呼叫.像这样: < asp:gridview id ="Employees" runat ="server" autogeneratecolumns ="true" xmlns:asp =#unknown"> asp:GridView> 祝你好运. Hi Using DataReader from a SQL Server stored procedure and load the data in the DataTable and populated a GridView with this DataTable. Does this make sence? Also import the System.Data.SqlClient namespace. eg: This needs to go into the top (above the head) of your page code: protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { BindGrid(); } } private void BindGrid() { SqlConnection objConn = new SqlConnection("Server=YourServer;UID=user;PWD=pass;Database=YourDatabase"); SqlCommand objCmd = new SqlCommand("GetAllEmployees", objConn); objCmd.CommandType = CommandType.StoredProcedure; objConn.Open(); SqlDataReader DR = objCmd.ExecuteReader(); Employees.DataSource = DR; Employees.DataBind(); DR.Close(); DR = null; objCmd.Dispose(); objCmd = null; objConn.Close(); objConn = null; } Then use it in your form inside your body to call. like this: <asp:gridview id="Employees" runat="server" autogeneratecolumns="true" xmlns:asp="#unknown">asp:GridView> Good luck.
更多推荐
如何使用Windows应用程序使用来自sqlserver的数据填充Web表单.
发布评论