下面是对xml,access,mssql数据存取
protected dataset loadmypbdata()
{
string sourcexml = server.mappath("phone.xml");
dataset dataset = new dataset();
try
{
dataset.readxml(sourcexml);
}
catch (exception e)
{
dataset = null;
}
return dataset;
}
void page_load(object sender, eventargs e)
{
if (!(page.ispostback))
{
gridv.datasource = loadmypbdata();
gridv.databind();
}
}
-------------------------------
string strsql="data source=127.0.0.1;initial catalog=do.net;persist security info=true;user id=sa;password=1234;packet size=4096";
sqlconnection myconn = new sqlconnection(strsql);
myconn.open();
string commsql = "select * from gbook order by id desc";
sqldataadapter adp = new sqldataadapter(commsql,myconn);
dataset ds = new dataset();
adp.fill(ds);
datagrid1.datasource = ds;
datagrid1.databind();
myconn.close();
---------------------------------------
if(!ispostback)
{
oledbconnection myconnection =new oledbconnection("provider=microsoft.jet.oledb.4.0;data source="+server.mappath("new.mdb"));
oledbdataadapter mycommand=new oledbdataadapter("select id,typename from bb ",myconnection);
dataset ds= new dataset();
mycommand.fill(ds,"bb");
dropdownlist2.datasource = ds.tables["bb"].defaultview;
dropdownlist2.datatextfield = "typename";
dropdownlist2.datavaluefield = "id";
dropdownlist2.databind();
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器