10分求助:web.config里的一个小错误!是关于连接数据库的。。。。。
我的web.config里:
<add key= "datapath " value= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\new.mdb " ProviderName= "System.Data.OLEDB "/>
.cs里:
OleDbConnection conn=new OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings[ "datapath "]);
conn.Open();
string sql= "select top 10 * FROM aa WHERE typeid=1 order by shijian desc ";
OleDbCommand comm=new OleDbCommand(sql,conn);
OleDbDataReader dr=comm.ExecuteReader(CommandBehavior.CloseConnection);
biaoti=dr[ "biaoti "].ToString();
.aspx里:
<% =biaoti %>
应该是web.config里写错了,就是后面的 ProviderName= "System.Data.OLEDB "这里
还有个问题就是我不想把数据库放到app-code里请问该如何写webconfig啊?
谢谢csdn高手们!
[解决办法]
string datas = AppDomain.CurrentDomain.BaseDirectory+ "database\\news.mdb ";
string conn = "Provider=Microsoft.Jet.OLEDB.4.0;data source= "+datas;