如何使用Windows应用程序使用来自sqlserver的数据填充Web表单.

编程入门 行业动态 更新时间:2024-10-28 04:27:01
本文介绍了如何使用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表单.

本文发布于:2023-10-05 11:58:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1467361.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   如何使用   应用程序   数据   sqlserver

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!