| | |
Connect to access database on a shared folder
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
You can create DSN and use ODBC model in your .net application.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Feb 2008
Posts: 38
Reputation:
Solved Threads: 0
I know how to connect to MS Access database in a local folder, but my problem is that I don't know how to do this if the database is in a shared folder.
I tried to use this connection string in a Windows application but unfortunately it failed:
When I execute the program, the compiler show me that the database: C:\Documents and Settings\...\@\ServerName\SharedDocs\CS\db1.mdb is not a valid path.
Thanks for your help
I tried to use this connection string in a Windows application but unfortunately it failed:
C# Syntax (Toggle Plain Text)
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=@\\ServerName\\SharedDocs\\CS\\db1.mdb; Jet OLEDB:System Database=system.mdw;").
When I execute the program, the compiler show me that the database: C:\Documents and Settings\...\@\ServerName\SharedDocs\CS\db1.mdb is not a valid path.
Thanks for your help
Because '\\' means relative path!! not shared path
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
UNC path, browse it, I developed application runs on db in shared location.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
You don't have enough back slashes in there.
If it's a UNC path like this:
\\server\sharename\file.mdb
in C# it would look like:
"\\\\server\\sharename\\file.mdb"
or @"\\server\sharename\file.mdb"
the @ symbol will make it a string literal that doesn't need to be escaped with the extra backslashes.
If it's a UNC path like this:
\\server\sharename\file.mdb
in C# it would look like:
"\\\\server\\sharename\\file.mdb"
or @"\\server\sharename\file.mdb"
the @ symbol will make it a string literal that doesn't need to be escaped with the extra backslashes.
Alex Cavnar, aka alc6379
•
•
Join Date: May 2008
Posts: 9
Reputation:
Solved Threads: 0
HI guys,
i am getting error :
System.Data.Oledb.OleDbExcption : Sybtax error in INSERT INTO sataement.
here a part of my code :
public void Submit()
{
objCommandBuilder = new OleDbCommandBuilder(aAdapter);
// Obtain a new DataRow object from the table Call_Log
insertedRow = table_Call_Log.NewRow();
//CallerComboBox.SelectedItem.ToString();
// Set the DataRow field values as necessary.
insertedRow["Calling_Rep"] = "calling rep";
//insertedRow["Date_of_Call"] = DateTime.Now;
insertedRow["Unnecessary_Call"] = CheckBox1.Checked;
try
{
// Pass that new object into the Add method of the DataTable.
table_Call_Log.Rows.Add(insertedRow);
// Begin send changes to MS Access
aAdapter.UpdateCommand = objCommandBuilder.GetInsertCommand();
//aAdapter.UpdateCommand = objCommandBuilder.GetUpdateCommand();
aAdapter.Update(aDataSet,"Call_Log");
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
i am getting error :
System.Data.Oledb.OleDbExcption : Sybtax error in INSERT INTO sataement.
here a part of my code :
public void Submit()
{
objCommandBuilder = new OleDbCommandBuilder(aAdapter);
// Obtain a new DataRow object from the table Call_Log
insertedRow = table_Call_Log.NewRow();
//CallerComboBox.SelectedItem.ToString();
// Set the DataRow field values as necessary.
insertedRow["Calling_Rep"] = "calling rep";
//insertedRow["Date_of_Call"] = DateTime.Now;
insertedRow["Unnecessary_Call"] = CheckBox1.Checked;
try
{
// Pass that new object into the Add method of the DataTable.
table_Call_Log.Rows.Add(insertedRow);
// Begin send changes to MS Access
aAdapter.UpdateCommand = objCommandBuilder.GetInsertCommand();
//aAdapter.UpdateCommand = objCommandBuilder.GetUpdateCommand();
aAdapter.Update(aDataSet,"Call_Log");
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
![]() |
Similar Threads
- connect to access database over network (C#)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Access Problems (Windows Software)
Other Threads in the C# Forum
- Previous Thread: Get data from Access instead of Notepad (URGENT)
- Next Thread: Conversion problem
Views: 6195 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms ftp function gcd gdi+ http httpwebrequest image index input install java label list listbox listener login math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource saving serialization server sleep socket sql statistics stream string tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






