locked
Connecting to access database remotely. RRS feed

  • Question

  • User-344677108 posted

     

    Connecting to access database remotely.

     

    I have to connect access data base from my ASP.net application.

    Constraints

    1. I don’t know OLEDB driver is installed in server or not?  
    2. I don’t have access to server by any means.
    3. I tried to connect with different connection string, but I got the null reference error.

     

    1. Is it because of Oledb exception  which might not be installed in server?

     

    Please let me know if there is any universal data provider or DLL which I can put in my application to access the access database.

    public static void NConnect(string connect)

    {

    try

    {

    string subject = "Test.";

    OleDbConnection connectionData =

    new OleDbConnection(connect);

    connectionData.Open();

    OleDbCommand retrieveAllContraintes =

    new OleDbCommand(

    "SELECT emp FROM TBLemp WHERE Departement = '145'",

    connectionData);

    constraintList =

    new DataTable();

    OleDbDataAdapter adapter =

    new OleDbDataAdapter(retrieveAllContraintes);

    adapter.Fill(constraintList);

    subject =

    "Successful Connection" + constraintList.Rows.Count.ToString();

    connectionData.Close();

    MyBLL.SendEmail(

    "donotreply@gmail.com", "giri@gmail.com", subject, "Successfull Connection : " + connect);

    }

    catch (OleDbException ex)

    {

    MyBLL.SendEmail(

    "donotreply@gmail.com", "giri@gmail.com", "ERROR.", "Failed Connection :" + connect + ex.ToString());

    }

    }

    /// <summary>

    /// This method is use to test the connection to databases.

    /// </summary>

    public static void ForTestingPurposeCoonections()

    {

    List<

    string> connections = new List<string>();

    string message = "Starting test";

    string subject = "Connect to Nivelment tests are completed .";

    connections.Add(

    @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Path\Test.mdb;Jet OLEDB:System Database=system.mdw;Jet OLEDB:Database Password='Test';");

    connections.Add(

    @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Path\Test.mdb;Jet OLEDB:System Database=system.mdw;Jet OLEDB:Database Password=1careDat@Transf3r;");

    connections.Add(

    @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Path\Test.mdb;User Id=LogUser1;Password=1careDat@Transf3r;");

    connections.Add(

    @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Path\Test.mdb;Jet OLEDB:System Database=system.mdw;User Id=LogUser1;Password='Test';");

    connections.Add(

    @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Path\Test.mdb;Jet OLEDB:System Database=system.mdw;User Id=LogUser1;Jet OLEDB:Database Password=Test;");

    connections.Add(

    @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Path\Test.mdb;Jet OLEDB:System Database=system.mdw;");

    connections.Add(

    @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Path\Test.mdb;Jet OLEDB:System Database=system.mdw;");

    ExportImportBLL.SendEmail(

    "donotreply@gmail.com", "giri@gmail.com", "Started", "Test Started Connections");

    foreach (string connect in connections)

    {

    MyBLL.SendEmail(

    "donotreply@gmail.com", "giri@gmail.com", "1", "End Connections 1");

    message =

    string.Empty;

    message = connect.ToString();

    NConnect(connect);

    MyBLL.SendEmail(

    "donotreply@gmail.com", "giri@gmail.com", "1", "End Connections 1");

    }

    MyBLL.SendEmail(

    "donotreply@gmail.com", "giri@gmail.com", subject, "Test Done , if you didnt recive any mail then all the tests are been failed.");

    Tuesday, February 28, 2012 10:02 AM

Answers

  • User-1199946673 posted

    Yes i read the blog , but it says about the access which is there in App_Data folder.

    But mine is in remote server which i need to connect from my site server.

    I understand. But the blog is clearly explaining which user you need to give which permissions. Ussually this is the App_Data folder, but if you want to use another location that doesn't matter, you still need to give permissions to the user. And there your problem starts, because you said you don't have access to that server, that's why I said most attempts will fail.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 1, 2012 4:27 PM

All replies

  • User863028031 posted

    You must add DSN on your server and you connect with that DSN.

    Tuesday, February 28, 2012 10:32 AM
  • User-344677108 posted

    Sorry , I dont have the access to server

    Tuesday, February 28, 2012 10:35 AM
  • User3866881 posted

    Hello grish.c:)

    Make sure that your Server can totally run Access and can be accessed successfully,and your client should install OLEDB Access by installing Office2003/2007(Recommanded)。

    Also you can download the only driver for Access:

    for 2010/2007:http://www.microsoft.com/download/en/details.aspx?id=13255

    For 2003:http://www.microsoft.com/download/en/details.aspx?id=21373

    Wednesday, February 29, 2012 9:54 PM
  • User-1199946673 posted

    • I don’t have access to server by any means.

    Well, To connect to an Access database, you will need to have permissions on the folder where the Access database is located. That's the reason most attempts to connect to remote Access databases will fail....

    Thursday, March 1, 2012 4:42 AM
  • User-344677108 posted

    Yes , server has the access to the folder where access DB is located.

    But there is no microsoft office tools like word or access is installed. So just would like to know is there any way i can connect to access without installing the driver or config the DSN IN SERVER

    Thank you

    Girish

     

    Thursday, March 1, 2012 8:54 AM
  • User-344677108 posted

    Thank you for the response ,But there is no microsoft office tools like word or access is installed. So just would like to know is there any way i can connect to access without installing the driver or config the DSN IN SERVER.

    As i said before , clients are not ready to install any drivers .

    Thank you

    Girish

    Thursday, March 1, 2012 8:55 AM
  • User-1199946673 posted

    Yes , server has the access to the folder where access DB is located.

    But there is no microsoft office tools like word or access is installed.

    To connect to an Access Database, you can use the Jet OleDb 4.0 driver, which is installed by default on any windows platform.

    http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET

    But as I said before, you need to have permissions:

    http://www.mikesdotnetting.com/Article/74/Solving-the-Operation-Must-Use-An-Updateable-Query-error

     

    Thursday, March 1, 2012 10:40 AM
  • User-344677108 posted

    Yes i read the blog , but it says about the access which is there in App_Data folder.

    But mine is in remote server which i need to connect from my site server. But i have the access to that folder.

    From my system i can connect , everything is working fine .Coz i have the Oledb driver and DSN.

    But in server thats not the case, please suggest.

    Thursday, March 1, 2012 12:46 PM
  • User-344677108 posted

    Thank you  for the responses, please let me know if any one is having any solution for the issue.

     

    Thursday, March 1, 2012 12:46 PM
  • User-1199946673 posted

    Yes i read the blog , but it says about the access which is there in App_Data folder.

    But mine is in remote server which i need to connect from my site server.

    I understand. But the blog is clearly explaining which user you need to give which permissions. Ussually this is the App_Data folder, but if you want to use another location that doesn't matter, you still need to give permissions to the user. And there your problem starts, because you said you don't have access to that server, that's why I said most attempts will fail.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 1, 2012 4:27 PM
  • User-344677108 posted

    Sorry if my communication was not proper,

    I mentioned i  have access to acceess DB (remote server or folder) from my ASP.net application server.

    I got the access to access db folder from my serever after raising the request to IT helpdesk.

    Ok i will try tmrw once again and let you know , i will again go through the blog.

     Thank you very much for the help hope we will find the solution soon. Good Day.

     

    Thursday, March 1, 2012 4:34 PM