当前位置:编程学习 > C#/ASP.NET >>

asp.net高手救急!!!

DataList控件如何绑定access数据库呀?
最好发段代码给我参考参考叭!!!!
补充:大哥们呀..咋还是显示不出数据呢?
答案:
using System.Data;
using System.Data.OleDb;
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:BegASPNETNorthwind.mdb";
OleDbConnection objConnection=new OleDbConnection(strConnection);
..
objConnection.Open();
//引用上面的朋友一点代码,,.
DataAdapter.SelectCommand.CommandText = "sql 语句";
DataSet result = new DataSet();
DataAdapter.Fill(result);
DataList.DataSource=result ;
DataList.DataBind();

objConnection.Close();

OleDbConnection conn = new OleDbConnection("链接字符串");

OleDbDataAdapter DataAdapter = new OleDbDataAdapter();
DataAdapter.SelectCommand = new OleDbCommand();
DataAdapter.SelectCommand.CommandText = "sql 语句";
DataSet result = new DataSet();
DataAdapter.Fill(result);
DataList.DataSource=result ;
DataList.DataBind();
ssds
如果是vs2003就要用:
DataList.DataSource=result.Tables[0].defaultview;
DataList.DataBind();

上一个:asp.net关于Treeview
下一个:ASP判断表是否存在

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,