首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 软件时空 > 软件相关 > 工程范例
【标  题】:工程范例
【关键字】:
【来  源】:http://blog.csdn.net/cesium/archive/2007/03/01/1518551.aspx

工程范例

  

类库文件(DBoper.cs):

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace DBManage
{
    public class DBoper
    {
        public static DataSet getCustomers(string ContactTitle, string Conn)
        {
            string str = "select * from Customers where ContactTitle=@ContactTitle";
            SqlConnection sqlConn = new SqlConnection(Conn);
            sqlConn.Open();
            SqlCommand sqlCmd = new SqlCommand(str, sqlConn);
            SqlParameter ConTitle = new SqlParameter("@ContactTitle",SqlDbType.NVarChar,20);
            ConTitle.Value = ContactTitle;
            sqlCmd.Parameters.Add(ConTitle);
            SqlDataAdapter sqlAdpor = new SqlDataAdapter(sqlCmd);
            DataSet ds = new DataSet();
            sqlAdpor.Fill(ds,"Customers");
            sqlConn.Close();
            return ds;

        }
    }
}

首页文件((Default.aspx):

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="test.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#E3EAEB" />
            <EditRowStyle BackColor="#7C6F57" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
   
    </div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    </form>
</body>
</html>

后台文件(Default.aspx,cs):

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBManage;
using System.Configuration;

namespace test
{

    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string contitle;
            string Conn = ConfigurationManager.AppSettings["sqlConnectionString"];
            contitle = TextBox1.Text;
            GridView1.DataSource= DBoper.getCustomers(contitle, Conn);
            GridView1.DataBind();
        }
    }
}

过程:先编写类库,然后将其编译,生成dll文件,并在网页工程中添加引用,最后在工程中调用

 

 

 

 

 

要让软件项目失败很容易:【上一篇】
为什么大的网络公司都选择开源软件作为其主要开发工具和平台?:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • 论面向对象设计和市场经济的相同之处
  • ADSL Modem之IP端口的设定及应用
  • VBScript Global 属性
  • O/R Mapping
  • NDoc Reloading ...
  • linux下的实现WIN下tree的shell
  • PHOTOSHOP绘制卡通人物详细教程
  • 关于防病毒的一些看法(原创)
  • Linux 入门时必学60文件处理个命令
  • recover database in time point
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.