日期:2014-05-19  浏览次数:20464 次

帮帮忙乎
哪位帮俺看看这段代码!   错误提示:

不支持关键字:   “provider”。  
说明:   执行当前   Web   请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  

异常详细信息:   System.ArgumentException:   不支持关键字:   “provider”。

public   partial   class   message   :   System.Web.UI.Page
{
        public     string     postid;
        public   void   Excutesql(string   strsql)
        {
                string   connstr   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= 'D:/Documents   and   Settings/Administrator/My   Documents/Visual   Studio   2005/BBS论坛/App_Data/bbsdata.mdb ' ";
                OleDbConnection   oleconnection   =   new   OleDbConnection(connstr);

                oleconnection.Open();
                OleDbCommand   cmd   =   new   OleDbCommand(strsql,   oleconnection);
                cmd.ExecuteNonQuery();
                oleconnection.Close();
                oleconnection.Dispose();
        }
        public   void   updata_view()
        {
                string   strsql   =   "update   newpost   set   views=views+1   where   postid= ' "+postid   + " ' ";
                Excutesql(strsql);
        }

        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                postid   =   Request[ "postid "]   ==   null   ?   " "   :   Request[ "postid "].ToString   ();
                updata_view();
        }
        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
                Response.Redirect( "reply.aspx?postid= "   +   postid);
        }
        protected   void   Button2_Click(object   sender,   EventArgs   e)
        {
                Response.Redirect( "newpost.aspx ");
        }
}
怎么回事?

------解决方案--------------------
应该是链接字符串错误

请参考
www.connectionstrings.com
------解决方案--------------------
OLE DB, OleDbConnection (.NET)

Standard security

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;


With database password
This is the connection