hi there,

i have a project which is build in visaul studio 2008 with the database used the mdf file. how can i keep the mdf file in a local network so that everbody can access if from the application. how can i do this.

i want the mdf file to be in a place in the network so that everybody can access. how can i do this


thankxxxx

make a shared drive and make surre all can access it .If you have web application then only your webapplication should be able to access it and you configure it as web.config file but if you have windows application or rich client
then either all users should acccess that folder and mdf file give rights to everyone on that shared folder through windows permission

make a shared drive and make surre all can access it .If you have web application then only your webapplication should be able to access it and you configure it as web.config file but if you have windows application or rich client
then either all users should acccess that folder and mdf file give rights to everyone on that shared folder through windows permission

hey,

how can i do if it is a desktop application???

thanxxxxxxxx

i told u make a shared folder and that should have this file
\\dvsql10\ETL_Scripts\
something like this
Then give access to everyone right click folder sharing
and then permission and then select everone

this is for access database

Standard security
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\10.2.55.184\Share\Team\mydatabase.mdb;User Id=admin;Password=;
How to Use JET in 64 bit environments >>

With database password
This is the connection string to use when you have an access database protected with a password using the Set Database Password function in Access.
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\10.2.55.184\Share\Team\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;


Workgroup (system database)
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\10.2.55.184\Share\Team\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;


Workgroup (system database) specifying username and password
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\10.2.55.184\Share\Team\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;


DataDirectory functionality
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myDatabase.mdb;User Id=admin;Password=;
Workgroup (system database) specifying username and password
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\10.2.55.184\Share\Team\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;


DataDirectory functionality
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\myDatabase.mdb;User Id=admin;Password=;


everybody should have access to this location \\10.2.55.184\Share\Team\mydatabase.mdb
thats how it will work
its shared file concept
one more thing dnt use access mdf file

put it into sql server


Now For SQL db

SqlConnection cn = new SqlConnection (@“Data Source=.\SQLEXPRESS; Integrated Security=True;"+
@"AttachDbFilename=C:\MyApplication\MyDatabase.mdf;Initial Catalog=MyDatabase");
cn.Open();

so this is c# code to do query SQL mdf file

Please note sql mdf file is different from access database


here also

the trick is to move this databse mdf file to sqlexpress and create a database suppose myDataBase .


CREATE DATABASE myDataBase
ON PRIMARY (FILENAME = 'C:\dat.mdf')
FOR ATTACH
GO

drop database your_database_name
GO


then change connection string to

Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;

Edited 6 Years Ago by jinus: n/a

send me connection string i will make it to you.

this is the connection string

private static string constring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\awaduge\My Documents\Visual Studio 2008\Projects\11th June 2010\AdminApplication\AdminApplication\AdminDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";


when i create a exe file and the mdf file is in shared folder is the conneection string going to be the same for each person that logs in through a windows login.

thanxxx

i told you create real databse out of this mdf and then you dont need this mdf file


CREATE DATABASE myDataBase
ON PRIMARY (FILENAME = 'C:\Documents and Settings\awaduge\My Documents\Visual Studio 2008\Projects\11th June 2010\AdminApplication\AdminApplication\AdminDB.mdf')
FOR ATTACH
GO
make sql authenticated user like myusername and password
CREATE LOGIN myUsername
WITH PASSWORD = '340$Uuxwp7Mcxo7Khy';
USE AdventureWorks2008R2;
CREATE USER myUsername FOR LOGIN myUsername;

Data Source=.\SQLEXPRESS;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;


windows login cant be used in this case as all user should have windows user if you wanna do this

then connection string willl be
Data Source=.\SQLEXPRESS;Database=myDataBase;Integrated
Security=SSPI

in all these case you have to give windows user /or group acccess to you db

i told you create real databse out of this mdf and then you dont need this mdf file


CREATE DATABASE myDataBase
ON PRIMARY (FILENAME = 'C:\Documents and Settings\awaduge\My Documents\Visual Studio 2008\Projects\11th June 2010\AdminApplication\AdminApplication\AdminDB.mdf')
FOR ATTACH
GO
make sql authenticated user like myusername and password
CREATE LOGIN myUsername
WITH PASSWORD = '340$Uuxwp7Mcxo7Khy';
USE AdventureWorks2008R2;
CREATE USER myUsername FOR LOGIN myUsername;

Data Source=.\SQLEXPRESS;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;


windows login cant be used in this case as all user should have windows user if you wanna do this

then connection string willl be
Data Source=.\SQLEXPRESS;Database=myDataBase;Integrated
Security=SSPI

in all these case you have to give windows user /or group acccess to you db

hey,
i don't have a actuall MS SQL server that i y i am trying to use the mdf file
how can i make it accessible by everyone in the network so that the desktop application that i have made can access and insert and updatre the same mdf file
how can i do this

thanxxxxxxx

this is the connection string

private static string constring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\awaduge\My Documents\Visual Studio 2008\Projects\11th June 2010\AdminApplication\AdminApplication\AdminDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";


when i create a exe file and the mdf file is in shared folder is the conneection string going to be the same for each person that logs in through a windows login.

thanxxx

i do not have a server to create a database so that is y i am searching for a way that i can use the C# mdf file as a file i can access in a network by several persons

thanxxxxxxxx

Hey, im working on ma semester project. Ive made the application through windows forms in visual studio 2008. Right now the databse it uses is the sql database stored in the data directory.

NOw i would like to make this database common for a lota computers. how do i do this please let me knoww!please asap

thanks

This article has been dead for over six months. Start a new discussion instead.