Showing posts with label config. Show all posts
Showing posts with label config. Show all posts

Sunday, March 25, 2012

DataSet.xsd Path in App Config?

Hey all... what is the proper method for setting a Dataset.xsd path in your Settings.settings value:

Here's the app.config from settings.settings value:

<add name="ffgsCRM.My.MySettings.ffgscrmConnectionStringSQLCE"

connectionString="Data Source = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)\ffgsCRM.sdf"

providerName="Microsoft.SqlServerCe.Client" />

I have the above and wondered how to make the path dynamic to C:\Documents and Settings\USERNAME\Local Settings\Application Data\ffgsCRM.sdf in the settings.settings value.

Thanks a ton!!

Bill

I think what you want is to use the |DataDirectory| substitution. Eg "Data Source = |DataDirectory|\ffgsCRM.sdf"|||Thanks... but that only puts the .sdf in the bin and not where I need it. :)|||

To set the DataDirectory property, call the AppDomain.SetData method. If you do not set the DataDirectory property, the following default rules are applied to access the database folder:

?

For applications that are put in a folder on the user's computer, the database folder uses the application folder.

?

For applications that are running under ClickOnce, the database folder uses the specific data folder that is created.

Note The .NET Compact Framework does not support the AppDomain.SetData method on Microsoft Windows Mobile-based devices. If an application calls the AppDomain.SetData method on a Windows Mobile-based device, you receive an error message.

(from http://support.microsoft.com/kb/920700)

|||

|||

To be honest I think you missed the point that both Erik and I were making with the DataDirectory in the when you deploy using ClickOnce it will automatically set the path to the users docs & settings folder.

w.r.t making the dataset dynamic - you can always set the connection object on each of the tableadapters that are used to fill the dataset?

|||

Nick, I'm wrong and had an error in the deployment... sorry... I'm going to try and path the Dataset1 to the users c:\drive\somewhere and go from there.

Thanks,

Bill

|||

my bad...

|||Yea, but where to you use the call to AppDomain.SetData? I call it in the load routine of my start up form, and my data is still being directed to a data folder from the click once deployment, and not to the place I want it in my application executable folder. ? what the ?|||

I did a public in the main form that looks like this for my dataset.xsd:

Public CRMConnectionString As String = "Data Source = " & Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\CRM.sdf"

Now when my app is fired up or deployed the dataset looks for the local db that is in the users program files folder... works all the time as long as you have the local db in the folder.

Hope this helps,

Bill

DataSet.xsd Path in App Config?

Hey all... what is the proper method for setting a Dataset.xsd path in your Settings.settings value:

Here's the app.config from settings.settings value:

<add name="ffgsCRM.My.MySettings.ffgscrmConnectionStringSQLCE"

connectionString="Data Source = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)\ffgsCRM.sdf"

providerName="Microsoft.SqlServerCe.Client" />

I have the above and wondered how to make the path dynamic to C:\Documents and Settings\USERNAME\Local Settings\Application Data\ffgsCRM.sdf in the settings.settings value.

Thanks a ton!!

Bill

I think what you want is to use the |DataDirectory| substitution. Eg "Data Source = |DataDirectory|\ffgsCRM.sdf"|||Thanks... but that only puts the .sdf in the bin and not where I need it. :)|||

To set the DataDirectory property, call the AppDomain.SetData method. If you do not set the DataDirectory property, the following default rules are applied to access the database folder:

? For applications that are put in a folder on the user's computer, the database folder uses the application folder. ? For applications that are running under ClickOnce, the database folder uses the specific data folder that is created.

Note The .NET Compact Framework does not support the AppDomain.SetData method on Microsoft Windows Mobile-based devices. If an application calls the AppDomain.SetData method on a Windows Mobile-based device, you receive an error message.

(from http://support.microsoft.com/kb/920700)

|||

|||

To be honest I think you missed the point that both Erik and I were making with the DataDirectory in the when you deploy using ClickOnce it will automatically set the path to the users docs & settings folder.

w.r.t making the dataset dynamic - you can always set the connection object on each of the tableadapters that are used to fill the dataset?

|||

Nick, I'm wrong and had an error in the deployment... sorry... I'm going to try and path the Dataset1 to the users c:\drive\somewhere and go from there.

Thanks,

Bill

|||

my bad...

|||Yea, but where to you use the call to AppDomain.SetData? I call it in the load routine of my start up form, and my data is still being directed to a data folder from the click once deployment, and not to the place I want it in my application executable folder. ? what the ?|||

I did a public in the main form that looks like this for my dataset.xsd:

Public CRMConnectionString As String = "Data Source = " & Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\CRM.sdf"

Now when my app is fired up or deployed the dataset looks for the local db that is in the users program files folder... works all the time as long as you have the local db in the folder.

Hope this helps,

Bill

sql

Sunday, February 26, 2012

Databases mirrong configuration question!

Hi all,
i could not find the answer to this on the net so i asked it here.
If i setup mirroring with standard config:
1 server with sql5000 server with 1 named instance (principal)
1 server with sql5000 server with 1 named instance (mirror)
1 server with sql5000 server with 1 named instance( witness)
Then i add a second named instance on the principal with some databases.
Must i setup an new config with witness and mirror to setp mirroring for
these databases?Or is it just simply selecting the databases in the new
instance and mirror them to the existing Mirror server and witness?
Many thx
--
I drank alot of beer and ended up in the police department database.
Drank more beer and learned SQL in the dark hours.
DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
I love SQL :)Oeps....correction in my hurry i typed sql5000....:) that will take while...
Offcourse i mean SQL 2005 and a normal server ...not clustered.
--
"Hate_orphaned_users" wrote:
> Hi all,
> i could not find the answer to this on the net so i asked it here.
> If i setup mirroring with standard config:
> 1 server with sql5000 server with 1 named instance (principal)
> 1 server with sql5000 server with 1 named instance (mirror)
> 1 server with sql5000 server with 1 named instance( witness)
> Then i add a second named instance on the principal with some databases.
> Must i setup an new config with witness and mirror to setp mirroring for
> these databases?Or is it just simply selecting the databases in the new
> instance and mirror them to the existing Mirror server and witness?
> Many thx
> --
> I drank alot of beer and ended up in the police department database.
> Drank more beer and learned SQL in the dark hours.
> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
> I love SQL :)
>|||You use the same endpoints on the mirror and the witness. On the new instance, you need to add the
endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to enable mirroring.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote in message
news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...
> Oeps....correction in my hurry i typed sql5000....:) that will take while...
> Offcourse i mean SQL 2005 and a normal server ...not clustered.
> --
>
>
> "Hate_orphaned_users" wrote:
>> Hi all,
>> i could not find the answer to this on the net so i asked it here.
>> If i setup mirroring with standard config:
>> 1 server with sql5000 server with 1 named instance (principal)
>> 1 server with sql5000 server with 1 named instance (mirror)
>> 1 server with sql5000 server with 1 named instance( witness)
>> Then i add a second named instance on the principal with some databases.
>> Must i setup an new config with witness and mirror to setp mirroring for
>> these databases?Or is it just simply selecting the databases in the new
>> instance and mirror them to the existing Mirror server and witness?
>> Many thx
>> --
>> I drank alot of beer and ended up in the police department database.
>> Drank more beer and learned SQL in the dark hours.
>> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
>> I love SQL :)
>>|||thx !
--
"Tibor Karaszi" wrote:
> You use the same endpoints on the mirror and the witness. On the new instance, you need to add the
> endpoint. Then you need to do the BACKUP and ALTER DATABASE commands to enable mirroring.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Hate_orphaned_users" <Hateorphanedusers@.discussions.microsoft.com> wrote in message
> news:F4701A29-BF15-477C-A036-8E4FA2189F8D@.microsoft.com...
> > Oeps....correction in my hurry i typed sql5000....:) that will take while...
> > Offcourse i mean SQL 2005 and a normal server ...not clustered.
> > --
> >
> >
> >
> >
> >
> > "Hate_orphaned_users" wrote:
> >
> >> Hi all,
> >>
> >> i could not find the answer to this on the net so i asked it here.
> >> If i setup mirroring with standard config:
> >> 1 server with sql5000 server with 1 named instance (principal)
> >> 1 server with sql5000 server with 1 named instance (mirror)
> >> 1 server with sql5000 server with 1 named instance( witness)
> >> Then i add a second named instance on the principal with some databases.
> >> Must i setup an new config with witness and mirror to setp mirroring for
> >> these databases?Or is it just simply selecting the databases in the new
> >> instance and mirror them to the existing Mirror server and witness?
> >>
> >> Many thx
> >> --
> >> I drank alot of beer and ended up in the police department database.
> >> Drank more beer and learned SQL in the dark hours.
> >> DELETE FROM offenders WHERE Title=''MrAA'' AND Year=2006;
> >> I love SQL :)
> >>
> >>
>