我机子上装有ACCESS2000和SQL SERVER 2000 磁盘格式是FAT32格式的在ASP.NET中连接SQL数据库,总是出现登陆失败的提示,adapter.Fill(ds, "userinfo");这一句红色显示
连接语句我是检查了几遍也发给网友看过,都说没有错然后我再连接ACCESS数据库,这次是提示连接语句红色显示,而这条语句本也没有
语法错误那位大哥碰到过这种情况,这里是语句,还是数据库软件的原因可是,我用ASP程序连接数据库又可以

解决方案 »

  1.   

    我的操作系统是WIN XP的不知道不没有关系
      

  2.   

    连接字符串连接Sql server和access是不一样的.
    http://blog.csdn.net/ChengKing/archive/2005/10/14/504078.aspx
      

  3.   

    这是代码,就是一个简单的操作<%@ Page language="c#" Debug="true" %>
    <%@ Import Namespace="System.Data" %>
    <%//@ Import Namespace="System.Data.SqlClient" %>
    <%@ Import Namespace="System.Data.OleDb"%><html>
    <script language="c#" runat="server">
    protected void Page_Load(object sender,EventArgs e)
    {
    String strcon= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/db1.mdb");
    OleDbConnection myConnection =new OleDbConnection(strcon);
      myConnection.Open();
    DataSet ds  = new DataSet();
      OleDbDataAdapter adapter  = new OleDbDataAdapter("Select * from userinfo", myConnection);
    adapter.Fill(ds, "userinfo");
      mydg.DataSource = ds.Tables["userinfo"].DefaultView;
      mydg.DataBind();
    myConnection.Close();} </script>
    <body>
    <h3 align="center">List</h3>
    <asp:DataGrid ID="mydg" runat="server"
     AutoGenerateColumns="false"
     BackColor="#ccccff"
     BorderColor="#0B0000"
     ShowFooter="false"
     CellPadding="3"
     CellSpacing="0"
     Font-Name="verdana"
     Font-Size="8"
     HeaderStyle-BackColor="#aaaadd"
     EnableViewState="false">
     <columns>
      <asp:BoundColumn FooterText="&ETH;ò&iexcl;&iexcl;&ordm;&Aring;" DataField="id" />
    <asp:BoundColumn FooterText="&Atilde;&ucirc;&iexcl;&iexcl;&sup3;&AElig;" DataField="username"/>
    <asp:BoundColumn FooterText="&Atilde;è&iexcl;&iexcl;&Ecirc;&ouml;" DataField="addren"/>
     </columns>
     </asp:DataGrid>
    </body>
    </html>
      

  4.   

    这是错误提示:
    Server Error in '/temp' Application.
    --------------------------------------------------------------------------------A field or property with the name 'addren' was not found on the selected datasource. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: A field or property with the name 'addren' was not found on the selected datasource.Source Error: 
    Line 37:  adapter.Fill(ds, "userinfo");
    Line 38:   mydg.DataSource = ds.Tables["userinfo"].DefaultView;
    Line 39:   mydg.DataBind();
    Line 40:  myConnection.Close();
    Line 41: 
     Source File: E:\li\asp.net\data1.aspx    Line: 39 
      

  5.   

    表中userinfo没有addren字段,数据绑定时DataField="addren"/>
    又有,检查一下
      

  6.   

    A field or property with the name 'addren' was not found on the selected datasource.
    没有addren字段!