1.首先從網上下載驅動,安裝,設置 System DSN 屬性 name=kjdb ,Driver=Adaptive Server Anywhere 6.0 (ODBC配置安裝程式)測試連接成功。
2.開啟vs.net 2003,新建test.asox頁面,test.aspx.cs後台代碼: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls;
// //using System.Configuration; using System.Data.Odbc; namespace webs { /// <summary> /// Summary description for test. /// </summary> public class test : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid DataGrid1; private void Page_Load(object sender, System.EventArgs e) { OdbcConnection objconn; OdbcDataAdapter objada; string strconn; string strcomm; DataSet dataset1=new DataSet(); strconn="Driver={SYBASE SYSTEM 11};Srvr=kjdb;Database=kjdb;Uid=dba;pwd=;"; strcomm="select * from kqrb"; objconn= new OdbcConnection(strconn); objada=new OdbcDataAdapter(strcomm,objconn); objada.Fill(dataset1,"kqrb"); DataGrid1.DataSource=dataset1.Tables["kqrb"].DefaultView; DataGrid1.DataBind();
}
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load);
} #endregion
} } 3.利用Server Exploer檢查連接Sybase 6.0 數據庫服務器,成功。
4.編譯,成功。但是查看頁面,得到出錯信息。如下提示:
|
请发表评论