您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp.net >> 正文

Form code generator V1.1 by Steve Schofieldbate2 等级:中级(转载:aspfree)

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-28 我要参与讨论

  This article revolves around being plain lazy. When it comes to creating Form code based on some  database table, I hate it! This code sample goes along way in speeding this process up for me.   There still is some manual parts to finish up the form code but this takes care of remembering what columns are in the database table.    In future releases, we'll provide more functionality to further automate this but this is a big first step in my opinion!  The following four steps listed below can be followed and this will generate the ASP.NET code. A big thanks to Dave W. Webmaster of  for saving me on many things!!

Define what database you want to connect to in the config.web.  This is stored in the connection string
<configuration>
    <appsettings>
        <add key="dsn" value="server=localhost;uid=sa;pwd=;database=aspfree" />
    </appsettings>
</configuration>
Load the aspx page in your browser, select the table to create the Form code from
Select the checkboxs of which fields to be on the form
Copy and paste into your code..
Here is a screen shot of the File after following the above steps.



Here is the code:

<%@ Page Language="VB" EnableSessionState="False" EnableViewState="True" Trace="False" Debug="False" Strict="True" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="VB" runat="server">
Dim sqlText as String
Dim ds as New DataSet
Dim dbComm AS New SQLDataAdapter
Dim conn AS SQLConnection
Dim sqlServer as String

Sub Page_Load(sender As Object, e As EventArgs)

          SQLserver = GetSqlConn()
          conn = New SQLConnection(SQLserver)


          If Not IsPostBack then
                    sqlText = "select id, name from sysobjects where xtype='U' order by name"
                    dbComm = New SQLDataAdapter(sqlText,conn)
          dbComm.Fill(ds,"AllTables")
          tblList.DataSource = ds.Tables("AllTables").

[1] [2] [3] [4] [5] 下一页

在google里搜索更多Form code generator V1.1 by Steve Schofieldbate2 等级:中级(转载:aspfree)

Google
Web www.51ec.org
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
我来说两句 对此文章发表了评论
  昵 称: *必填    ·注册用户·
  评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
评 论
内 容

 
评论列表 (最新 评论仅限网友观点!)

供求信息




| 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明