熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

Asp.Net建立ODBC數據源連接

2022-06-13   來源: .NET編程 

  鏈接代碼如下

using System;
using SystemData;
using SystemConfiguration;
using SystemWeb;
using SystemWebSecurity;
using SystemWebUI;
using SystemWebUIWebControls;
using SystemWebUIWebControlsWebParts;
using SystemWebUIHtmlControls;
using SystemDataOdbc;

public partial class _Default : SystemWebUIPage
{
protected void Page_Load(object sender EventArgs e)
{

}
protected void Button_Click(object sender EventArgs e)
{
OdbcConnection oc = new OdbcConnection(Dsn=jb;uid=sa;pwd=;);
try
{
ocOpen();
OdbcDataAdapter OD = new OdbcDataAdapter(SELECT * from jobs oc);
DataSet ds = new DataSet();
ODFill(ds);
GridViewDataSource = ds;
GridViewDataBind();
ResponseWrite(<script language=javascript>alert(ODBC數據源連接成功!)</script>);
}
catch
{
ResponseWrite(<script language=javascript>alert(ODBC數據源連接失敗!)</script>);
}
}
}


From:http://tw.wingwit.com/Article/program/net/201311/15169.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.