给你个完整例子:更想起情况,联系yahoo通:zizhao_chen
解决方案 »
- maven中依赖包不自动下载了
- 求一条MYSQL 语句
- 如何用sql语句实现从服务器上MySQL数据库导出数据至本地
- 谁有mysql的m-s读写分离操作步骤 详细的文档
- mysql 怎么增加记录最长长度
- mysql在客户端修改root密码后,客户端能登陆,服务器上密码没变,新密码登陆不了,抑郁了,详见帖子!
- 请问如何远程让mysql重启?谢谢
- MySQL 如何在插入时得到该行的 id ?
- 谁帮忙把下面这个mysql的SQL语句转换成标准的SQL
- 上百个mysql实例管理
- 后台是Linux环境下的Mysql服务器。连接Mysql服务器时出现Can''t connect to local MySQL server。而在后台是Windows环境下的Mysql服务器,
- 谁知道,我用postgresql数据库连接时不用密码就能连接上了,postgresql的用户是设了密码的.
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;namespace Org.Lacl.Lacl
{
/// <summary>
/// utility 的摘要说明。
/// </summary>
public class Utility : System.ComponentModel.Component
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Utility(System.ComponentModel.IContainer container)
{
///
/// Windows.Forms 类撰写设计器支持所必需的
///
container.Add(this);
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} public Utility()
{
///
/// Windows.Forms 类撰写设计器支持所必需的
///
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{ }
#endregion public System.Data.IDbConnection GetDBConnection()
{
return new Npgsql.NpgsqlConnection(Configuration.NpgsqlConnectionString);;
}
}
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace Org.Lacl.Lacl
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class Default: System.Web.UI.Page
{
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.HyperLink HyperLink2;
protected System.Web.UI.WebControls.HyperLink HyperLink3;
protected System.Web.UI.WebControls.HyperLink HyperLink4;
protected Npgsql.NpgsqlConnection ConnectionLacl;
protected Npgsql.NpgsqlCommand CommandLacl;
protected Npgsql.NpgsqlDataReader DataReaderLacl; protected System.Web.UI.WebControls.DataList DataList1;
private void Page_Load(object sender, System.EventArgs e)
{
try
{
this.ConnectionLacl.ConnectionString=Configuration.NpgsqlConnectionString;
this.ConnectionLacl.Open();
this.CommandLacl.CommandText="select announcement_title,announcement_content,announcement_datetime,announcement_auther,announcement_id,announcement_isfront from announcement where announcement_isfront=TRUE order by announcement_datetime desc";
DataReaderLacl=this.CommandLacl.ExecuteReader();
this.DataList1.DataSource=DataReaderLacl;
this.DataList1.DataBind();
}
catch(Exception ee)
{
Page.RegisterStartupScript("conncetionExcetion","<script>alert('连接数据库错误:\n"+ee.Message+"')</script>");
}
finally
{
this.ConnectionLacl.Close();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ConnectionLacl = new Npgsql.NpgsqlConnection();
this.CommandLacl = new Npgsql.NpgsqlCommand();
//
// CommandLacl
//
this.CommandLacl.Connection = this.ConnectionLacl;
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}