sql server express connection

R

Richard Steele

Hi
I have a win app (allways running 24x7) (.net 2 c#) that uses sql server
express.
and i use the following connection string to attach it in the app.config
<connectionStrings>
<add name="Browser.Properties.Settings.DataConnectionString"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\data\Data.mdf;Integrated
Security=True;Connect Timeout=60;Database=papdata;User Instance=False;"
providerName="System.Data.SqlClient" />
</connectionStrings>


Every day a win service, using the same MDB updates/imports the data from
another source. This all works as expected. when the windows service has
completed its update, the win app is notified to refresh its data and show
the updates.

My issue, is that though the data has been refreshed and the win app
reconnects to the database to collect the updates (new datasets) it does not
reflect the updates, simply the older version. I think it is the way I have
attached the database (the win app starts first on sys reboot) is there a
better way of 2 apps using the same database without having to attach it.

Hope this makes sense
 
J

Jon Skeet [C# MVP]

I have a win app (allways running 24x7) (.net 2 c#) that uses sql server
express.
and i use the following connection string to attach it in the app.config
<connectionStrings>
<add name="Browser.Properties.Settings.DataConnectionString"
connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\data\Data.mdf;Integrated
Security=True;Connect Timeout=60;Database=papdata;User Instance=False;"
providerName="System.Data.SqlClient" />
</connectionStrings>

Every day a win service, using the same MDB updates/imports the data from
another source. This all works as expected. when the windows service has
completed its update, the win app is notified to refresh its data and show
the updates.

My issue, is that though the data has been refreshed and the win app
reconnects to the database to collect the updates (new datasets) it does not
reflect the updates, simply the older version. I think it is the way I have
attached the database (the win app starts first on sys reboot) is there a
better way of 2 apps using the same database without having to attach it.

I'm far from a SQL Server Express expert, but I suspect the issue is
that you're attaching to a specific file. I *believe* that if you
create it as a "normal" database that you connect to by name instead,
it'll be okay.

This is mostly guesswork though! It's probably worth asking on a SQL
server newsgroup.

Jon
 
P

Peter Bromberg [C# MVP]

Richard,
The AttachDbFilename= and UserInstance type of connection string creates a
UserInstance host process for the database, and is really designed for ease
of development. In production, you want to attach the MDF file from sql
server management console and use a "regular" connection string, e.g.

server=(local);database=mydb;uid=username;pwd=pass

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: htp://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top