给你个完整例子:更想起情况,联系yahoo通:zizhao_chen
解决方案 »
- 表再次错误!
- 用myisamchk修复数据表如现如下错误
- 求助//execl 表格导入到 mysql 中后中文完全为乱码//麻烦帮忙看看
- mysql
- 如何利用navcat工具才能导出这个bit类型的值
- 2个表完全相同,查找b表的每条记录是不是在a表中匹配怎么做?
- 如何在RH Linux9用源码安装MySQL4 ?
- 请教如何按一定的顺序修改某列的值
- select * from test_log where log_key = 'Test' like '%%'
- 数据库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
}
}