I am attempting for my program to read an access database from another computer connected in the same LAN network (intranet). This is the code that I am using:
namespace CalUnderFoot
{
public partial class Window1 : Window
{
CarsDBDataSet dataSet;
CarsDBDataSetTableAdapters.CarSchedulingTableAdapter adapter;
public Window1()
{
InitializeComponent();
System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection()
{
ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data source= \\UNDERFOOT-PC\CalUnderFootDB\CarsDB.mdb"
};
con.Open();
\\do stuff
It won't open the database from
\\UNDERFOOT-PC\CalUnderFootDB\CarsDB.mdb
It only generates another copy of itself in the same location of the program. I know this is a syntax issue and I am new to C#. So what am I missing here?
I double checked the network connection between the 2 computers and it's OK.
DISCLAIMER: Not really an answer to your problem, but I don't have enough reputation to add it as a comment.
Since you say you're new to C#, I assume you don't know about Linq to SQL . If you've never heard about it, I think you should check it out. It's a nice abstraction, and spares you of writing in-line SQL.
I notice that your connection string does not have credentials. Have you tried something like this:
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=\\UNDERFOOT-PC\CalUnderFootDB\CarsDB.mdb;
User Id=admin; Password=;
StackOverflow really needs to get rid of some of its stupid rules. I am posting this as an answer instead of a comment due to insufficient reputation.
Perhaps this link may be of help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.