C# .NET - urgent reply me

Asked By selva kumar on 22-Feb-12 02:13 AM
currently i write the connection string code given below,but these code used i am not access the database so please help me
  <connectionStrings>
    <add name="accessConStr"
   connectionString="Provider=MS Remote;Remote Provider=Microsoft.Jet.OLEDB.4.0;
   Remote Server=http:\\192.168.1.102:4242\\sample.com;
   Data Source=F:\\sample\\database\\ains.mdb" ></add>
  </connectionStrings>

note:
i want connect remote methord
Reena Jain replied to selva kumar on 22-Feb-12 02:22 AM
hi,

try to use this

conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;

hope this will help you
Web Star replied to selva kumar on 22-Feb-12 02:24 AM
The connection string is correct to connect remotely but you make sure they must have setup to RDS access on that server and then mdb file path should be correct.
Somesh Yadav replied to selva kumar on 22-Feb-12 02:36 AM
Hi,

If you want to use an OLE DB Provider on the remote machine

oConn.Open "Provider=MS Remote;" & _ 
           "Remote Server=http://myServerName;" & _
           "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=c:\somepath\mydb.mdb", _
            "admin", ""
 

If you want to use an OLE DB Provider on the remote machine

oConn.Open "Provider=MS Remote;" & _ 
           "Remote Server=http://myServerName;" & _
           "Handler=MSDFMAP.Handler;" & _
           "Data Source=MyAdvworksConn"

The corresponding entry in the \winnt\Msdfmap.ini file would be:

[connect MyAdvworksConn]
Access = ReadWrite
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;
           Data Source=mydb.mdb;
           User Id=admin; 
           Password="               (put all of this on single line!)

After that use below one.
conn
= System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;

Hope it helps you.
Sandeep Mittal replied to selva kumar on 22-Feb-12 02:59 AM
Refer the below link. It has connection strings for almost all databases

http://connectionstrings.com/
dipa ahuja replied to selva kumar on 22-Feb-12 03:56 AM
Always use the connectionString with relative path:

ASP.NET

<add name="ConnectionString"

connectionString="Data Source=.\SQLEXPRESS;

AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

Use in .cs:

string ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

C#

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <appSettings>

    <add key="name" value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"/>

  </appSettings>

</configuration>

string s = ConfigurationSettings.AppSettings["name"].ToString();