none
Web service not able to connect to microsoft access database RRS feed

  • Question

  • Hi,
    I am developing a web service application using Visual studio 2008 . I have got installed IIS 6.0 and windows server 2003 in my system. I am not able to connect to microsoft access database from web service application. I have configured the IIS 6.0 to ODBC logging according to the link http://support.microsoft.com/kb/245243 .  But the same application runs fine in windows application . Could you let me know where I am going wrong.

    Thanks & Regards,
    Haresh.V
    • Moved by Steve MaineMicrosoft employee Thursday, December 3, 2009 7:37 PM Question is about using ADO.NET to talk to Access databases from within a web service (From:ASMX Web Services and XML Serialization)
    Wednesday, December 2, 2009 3:20 PM

Answers

  • Hi All,

    I got the solution to the problem. The folder containing the .mdb file didn't have the permission for account ASPNET (for windows XP) or Network Service account (for windows server 2003). When I granted the read, write permission to the corresponding account I was able to access the microsoft access database.


        Thanks & Regards,
    Haresh.V
    • Marked as answer by Haresh_V Tuesday, December 15, 2009 5:04 AM
    Tuesday, December 15, 2009 5:04 AM

All replies

  • You have not provided any information that could help us answer your question!

    What exactly do  you mean when you say you are "unable to connect"? What exception are you receiving? Please post the complete exception, including all InnerException instances, but catching the exception, then displaying the result of ex.ToString().

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Thursday, December 3, 2009 12:09 AM
  • Hi John,
    Sorry, for not enclosing the exception details . We have created a web service using File-> Web site -> ASP.Web service in visual studio 2008. We are using an application api which is accessible through visual studio, after adding refernces to dlls . After defining the microsoft access database DSN name and login infomation , if I check for the connectivity using a bool type I am getting " False"  . If I do no check for connection of database in the code and using try n catch I am getting a " System.IndexOutORange.Exception ". The code is as follows

    public

     

    DataSet dsInspections = null;

     

    public Database dataBase = new Database();



    [WebMethod

     

    ]

     

    public DataSet AccessData()

    {

     

    //Create Dataset tables

    dsInspections =

    new DataSet();

     

    DataTable dtInspections = new DataTable();

    dtInspections.Columns.Add(

    "WkstName", typeof(System.String)).AllowDBNull = true;

    dtInspections.Columns.Add(

    "WkstId", typeof(System.String)).AllowDBNull = true;


    //DEFINE THE DATABASE DSN NAME & LOGIN INFORMATION

    dataBase.DSN =

    " microsoft access database";

    dataBase.UserName =

    "admin";

    dataBase.Password =

    "password";


     

    bool connected = dataBase.Connect((int)(DatabaseConnectOptionConstants.PromptNoResolve), dataBase.hWndOwner);

     

    if (!connected)

    {

     

     

     

    DataRow drInspections = dtInspections.NewRow();

    drInspections[0] =

    Convert.ToInt16(DatabaseConnectOptionConstants.PromptNoResolve).ToString() + ", " + connected.ToString();

    dtInspections.Rows.Add(drInspections);

     

    return dsInspections;

    }


     Exception:
    <?xml version="1.0" encoding="utf-8" ?>
    - <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    - <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    - <xs:complexType>
    - <xs:choice minOccurs="0" maxOccurs="unbounded">
    - <xs:element name="Table1">
    - <xs:complexType>
    - <xs:sequence>
      <xs:element name="WkstName" type="xs:string" minOccurs="0" />
      <xs:element name="WkstId" type="xs:string" minOccurs="0" />
     
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:choice>
      </xs:complexType>
      </xs:element>
      </xs:schema>
    - <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    - <NewDataSet xmlns="">
    - <Table1 diffgr:id="Table11" msdata:rowOrder="0" diffgr:hasChanges="inserted">
      <WkstName>2, False</WkstName>
      </Table1>
      </NewDataSet>
      </diffgr:diffgram>
      </DataSet>



    If I comment the connection logic and try to retrieve data from the tables present in the microsoft database I am getting the following exception



     

    try

    {

     

       if (oWkstInfo.Find(dataBase, 0))

         {  

              logic ;
          }

    }

       Exception:
    <?xml version="1.0" encoding="utf-8" ?>
    - <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    - <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    - <xs:complexType>
    - <xs:choice minOccurs="0" maxOccurs="unbounded">
    - <xs:element name="Table1">
    - <xs:complexType>
    - <xs:sequence>
      <xs:element name="WkstName" type="xs:string" minOccurs="0" />
      <xs:element name="WkstId" type="xs:string" minOccurs="0" />
        </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:choice>
      </xs:complexType>
      </xs:element>
      </xs:schema>
    - <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    - <NewDataSet xmlns="">
    - <Table1 diffgr:id="Table11" msdata:rowOrder="0" diffgr:hasChanges="inserted">
      <WkstName>System.IndexOutOfRangeException: Subscript out of range at WkstInfClass.Find(Database DB, Int32 Options) at Service.AccessData() in c:\Inetpub\wwwroot\MyWebService\App_Code\Service.cs:line 193</WkstName>
      </Table1>
      </NewDataSet>
      </diffgr:diffgram>
      </DataSet>



    I felt there is a problem in establishing the connection to the microsoft access database from the web service application. So I have configured the IIS 6.0 to ODBC logging according to the link http://support.microsoft.com/kb/245243 . Still I am facing the same problem.


    Thanks & Regards,
    Haresh.V










    Thursday, December 3, 2009 5:44 AM
  • IIS applications run with a different identity than the logged in user. You might be having security issues.

    This seems like its more appropriate for the ADO.NET forums, so I'm going to move this thread to a place where there will be a few more eyes on it.


    Brain.Save() -- http://hyperthink.net/blog
    Thursday, December 3, 2009 7:36 PM
  • Hi Steve,

    Thank you . So nice of you :)





    Thanks & Regards,
    Haresh.V


    Friday, December 4, 2009 6:15 AM
  • Hi All,

    I got the solution to the problem. The folder containing the .mdb file didn't have the permission for account ASPNET (for windows XP) or Network Service account (for windows server 2003). When I granted the read, write permission to the corresponding account I was able to access the microsoft access database.


        Thanks & Regards,
    Haresh.V
    • Marked as answer by Haresh_V Tuesday, December 15, 2009 5:04 AM
    Tuesday, December 15, 2009 5:04 AM