RE: [OzSilverlight] Linq to sql

2008-08-27 Thread Jordan Knight
Hi Stephen,

You are having a tricky few days :)

Sometimes LINQ to SQL config issues can arise when you have your LINQ classes 
in another assembly...

If this is the case you may be able to get around it by following these steps:


* In you LINQ to SQL designer (on the dbml file) - go to Properties and 
remove the Connection field.

* This re-creates the LINQ class with a new constructor that wasn't 
there before you can utilise to override connection strings

* Create a new cs file to house a partial class:
public partial class MainDataDataContext
{
public MainDataDataContext() :

base(System.Configuration.ConfigurationManager.ConnectionStrings[someConnSring].ConnectionString,
 mappingSource)
{
OnCreated();
}
}

MainDataDataContext is the same class that was created by the LINQ designer. 
This way you can explicitly control your connection string.




Regards,
Jordan Knight
Readify - Senior Developer
Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
M: +61 403 532 404 | E: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] | W: 
www.readify.nethttp://www.readify.net/

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen Price
Sent: Wednesday, 27 August 2008 11:17 PM
To: listserver@ozsilverlight.com
Subject: [OzSilverlight] Linq to sql

Hey all,

I was having a problem with my WCF web service talking to the database. I'm 
using Linq to SQL, and discovered that it stores the connection strings in 
settings in the project. If the string in the web.config is not found then it 
falls back to the connection string in the dll. (from settings). That's where I 
discovered my string seems to be an old string. Anyway I have gotten it talking 
to my webhost's database again (they moved the SQL server and it stopped 
working!).

The problem i'm having now is that on the server i'm trying to deploy my app to 
it's got a similar problem, it can't connect to the database. I wrote a command 
line app to make calls to the same assembly the webservice uses to call the 
database, and it has no problems connecting.
The connection string in the command's config and the string in the web.config 
is the same. I've tried changing it from (local) to 127.0.0.1http://127.0.0.1 
to the subnet ip address and all seem to fail. I see no hits on the database 
using SQL profiler. It has to be a connection string issue but I can't see it 
for looking. Any ideas anyone? oh, I've set up my local machine in a similar 
manner and it works (using (local)) so putting that up on the server you'd 
think it would work. Could be a cross domain thing but the webservice is 
working its just the database calls by the webservice are failing.

thanks!
Stephen
p.s. this was the problem I was trying to solve when I hit the other problem I 
posted earlier today. tough day!

--- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net



--- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.

Powered by mailenable.com - List managed by www.readify.net



RE: [OzSilverlight] Linq to sql

2008-08-27 Thread Jordan Knight
Yep, but by implementing the pattern below you can ensure the default 
constructor always uses the correct connection string - it's a preferential 
thing, but I like to encapsulate connection configuration in my data classes 
rather than pass connection strings through from my business code:)
Regards,
Jordan Knight
Readify - Senior Developer
Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
M: +61 403 532 404 | E: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] | W: 
www.readify.nethttp://www.readify.net/

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Nagy
Sent: Thursday, 28 August 2008 10:12 AM
To: listserver@ozSilverlight.com
Subject: RE: [OzSilverlight] Linq to sql

 This way you can explicitly control your connection string

Or you can just set the connection string to the right one when you instantiate 
your data context???
var db = new MainDataDataContext (SomeHelperClass.DefaultConnectionString);


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jordan Knight
Sent: Thursday, 28 August 2008 8:37 AM
To: listserver@ozSilverlight.com
Subject: RE: [OzSilverlight] Linq to sql

Hi Stephen,

You are having a tricky few days :)

Sometimes LINQ to SQL config issues can arise when you have your LINQ classes 
in another assembly...

If this is the case you may be able to get around it by following these steps:


* In you LINQ to SQL designer (on the dbml file) - go to Properties and 
remove the Connection field.

* This re-creates the LINQ class with a new constructor that wasn't 
there before you can utilise to override connection strings

* Create a new cs file to house a partial class:
public partial class MainDataDataContext
{
public MainDataDataContext() :

base(System.Configuration.ConfigurationManager.ConnectionStrings[someConnSring].ConnectionString,
 mappingSource)
{
OnCreated();
}
}

MainDataDataContext is the same class that was created by the LINQ designer. 
This way you can explicitly control your connection string.




Regards,
Jordan Knight
Readify - Senior Developer
Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
M: +61 403 532 404 | E: [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] | W: 
www.readify.nethttp://www.readify.net/

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen Price
Sent: Wednesday, 27 August 2008 11:17 PM
To: listserver@ozsilverlight.com
Subject: [OzSilverlight] Linq to sql

Hey all,

I was having a problem with my WCF web service talking to the database. I'm 
using Linq to SQL, and discovered that it stores the connection strings in 
settings in the project. If the string in the web.config is not found then it 
falls back to the connection string in the dll. (from settings). That's where I 
discovered my string seems to be an old string. Anyway I have gotten it talking 
to my webhost's database again (they moved the SQL server and it stopped 
working!).

The problem i'm having now is that on the server i'm trying to deploy my app to 
it's got a similar problem, it can't connect to the database. I wrote a command 
line app to make calls to the same assembly the webservice uses to call the 
database, and it has no problems connecting.
The connection string in the command's config and the string in the web.config 
is the same. I've tried changing it from (local) to 127.0.0.1http://127.0.0.1 
to the subnet ip address and all seem to fail. I see no hits on the database 
using SQL profiler. It has to be a connection string issue but I can't see it 
for looking. Any ideas anyone? oh, I've set up my local machine in a similar 
manner and it works (using (local)) so putting that up on the server you'd 
think it would work. Could be a cross domain thing but the webservice is 
working its just the database calls by the webservice are failing.

thanks!
Stephen
p.s. this was the problem I was trying to solve when I hit the other problem I 
posted earlier today. tough day!

--- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net
--- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net
--- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net



--- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.

Powered

Re: [OzSilverlight] Linq to sql

2008-08-27 Thread Stephen Price
I had established eventually that it was a case of an incorrect connection
string being used. I didn't know where it was getting the string from. I had
the connection string in the web.config but did not realise I had a number
of different strings in the Linq to sql assembly. I've found those (in the
settings for that project) and removed them all except for the correct one.
Now the name matches up with the named connection in the web config so it
works on my own web host.

I'm still stuck however on the server in the test environment. (I have three
environments, my own local  machine, my own personal web host, and my work's
test server. The work test server is still giving me problems connecting).

I wrote a command line program that uses the same assembly the web service
uses (yay for code seperation!) and when I run it locally on the test server
(same place the web service is running) then it can connect and bring back
data ok. the web service fails. The web service is using the same connection
string that is in the config file for the command program. I could set up
the code you suggested in the constructor but the command line program is
working so not sure if I need to?

I feel like i'm so close to solving it. I migth have to put in some logging
or something so I can see what it's trying to use for the connection. The
hardest part is not being able to remotely debug the thing. (Not sure how or
even if that's possible? not done it before)
thanks so much,
Stephen
On Thu, Aug 28, 2008 at 8:20 AM, Jordan Knight [EMAIL PROTECTED]wrote:

  Yep, but by implementing the pattern below you can ensure the default
 constructor always uses the correct connection string – it's a preferential
 thing, but I like to encapsulate connection configuration in my data classes
 rather than pass connection strings through from my business codeJ

 Regards,

 *Jordan Knight*
 Readify - Senior Developer

 Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
 M: +61 403 532 404 | E: [EMAIL PROTECTED] | W: www.readify.net



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Steven Nagy
 *Sent:* Thursday, 28 August 2008 10:12 AM

 *To:* listserver@ozSilverlight.com
 *Subject:* RE: [OzSilverlight] Linq to sql



  This way you can explicitly control your connection string



 Or you can just set the connection string to the right one when you
 instantiate your data context???

 var db = new MainDataDataContext(SomeHelperClass.DefaultConnectionString);





 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Jordan Knight
 *Sent:* Thursday, 28 August 2008 8:37 AM
 *To:* listserver@ozSilverlight.com
 *Subject:* RE: [OzSilverlight] Linq to sql



 Hi Stephen,



 You are having a tricky few days J



 Sometimes LINQ to SQL config issues can arise when you have your LINQ
 classes in another assembly...



 If this is the case you may be able to get around it by following these
 steps:



 · In you LINQ to SQL designer (on the dbml file) – go to
 Properties and remove the Connection field.

 · This re-creates the LINQ class with a new constructor that
 wasn't there before you can utilise to override connection strings

 · Create a new cs file to house a partial class:

 public partial class MainDataDataContext

 {

 public MainDataDataContext() :

 base(System.Configuration.ConfigurationManager
 .ConnectionStrings[someConnSring].ConnectionString, mappingSource)

 {

 OnCreated();

 }

 }



 MainDataDataContext is the same class that was created by the LINQ
 designer. This way you can explicitly control your connection string.









 Regards,

 *Jordan Knight*
 Readify - Senior Developer

 Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
 M: +61 403 532 404 | E: [EMAIL PROTECTED] | W: www.readify.net



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Stephen Price
 *Sent:* Wednesday, 27 August 2008 11:17 PM
 *To:* listserver@ozsilverlight.com
 *Subject:* [OzSilverlight] Linq to sql



 Hey all,



 I was having a problem with my WCF web service talking to the database. I'm
 using Linq to SQL, and discovered that it stores the connection strings in
 settings in the project. If the string in the web.config is not found then
 it falls back to the connection string in the dll. (from settings). That's
 where I discovered my string seems to be an old string. Anyway I have gotten
 it talking to my webhost's database again (they moved the SQL server and it
 stopped working!).



 The problem i'm having now is that on the server i'm trying to deploy my
 app to it's got a similar problem, it can't connect to the database. I wrote
 a command line app to make calls to the same assembly the webservice uses to
 call the database, and it has no problems connecting.

 The connection string in the command's config and the string in the
 web.config is the same. I've

Re: [OzSilverlight] Linq to sql

2008-08-27 Thread Stephen Price
Have the Serialization Mode set correctly, I knew about that one. I didn't
realise you could remove the connection string from there. That would
possibly help make things clearer. If I know there's only one connection
string it can use then I'll feel happier it's using it. Will give that a
try...

So how does it know which connections string in the Application config file
to use? and which config file? The one belonging to the assembly or the
web.config? My understanding of how this works is that the assembly has a
nameofassembly.config which is used for things such as Unit tests etc, and
then if you deploy it with a webapp and it has a web.config then the
web.config overrides the assembly's config (does it just ignore it or does
it load one value from assembly config then the same value is over written
when the web.config is loaded?)

On Thu, Aug 28, 2008 at 8:34 AM, .net noobie [EMAIL PROTECTED] wrote:

 you can also just set it in the properties dialog for the .dbml

 and also note (just in case you did not already know) that you should set
 the

 *Serialization Mode* = *Unidirectional*

 if you want to send data from the LinqToSql .dbml via a WCF service to a
 Silverlight Application

 i attached a pic incase I am not being clear...




 On 8/28/08, Steven Nagy [EMAIL PROTECTED] wrote:

   This way you can explicitly control your connection string



 Or you can just set the connection string to the right one when you
 instantiate your data context???

 var db = new MainDataDataContext(SomeHelperClass.DefaultConnectionString);





 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Jordan Knight
 *Sent:* Thursday, 28 August 2008 8:37 AM
 *To:* listserver@ozSilverlight.com
 *Subject:* RE: [OzSilverlight] Linq to sql



 Hi Stephen,



 You are having a tricky few days J



 Sometimes LINQ to SQL config issues can arise when you have your LINQ
 classes in another assembly...



 If this is the case you may be able to get around it by following these
 steps:



 · In you LINQ to SQL designer (on the dbml file) – go to
 Properties and remove the Connection field.

 · This re-creates the LINQ class with a new constructor that
 wasn't there before you can utilise to override connection strings

 · Create a new cs file to house a partial class:

 public partial class MainDataDataContext

 {

 public MainDataDataContext() :

 base(System.Configuration.ConfigurationManager
 .ConnectionStrings[someConnSring].ConnectionString, mappingSource)

 {

 OnCreated();

 }

 }



 MainDataDataContext is the same class that was created by the LINQ
 designer. This way you can explicitly control your connection string.









 Regards,

 *Jordan Knight*
 Readify - Senior Developer

 Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
 M: +61 403 532 404 | E: [EMAIL PROTECTED] | W: www.readify.net



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Stephen Price
 *Sent:* Wednesday, 27 August 2008 11:17 PM
 *To:* listserver@ozsilverlight.com
 *Subject:* [OzSilverlight] Linq to sql



 Hey all,



 I was having a problem with my WCF web service talking to the database.
 I'm using Linq to SQL, and discovered that it stores the connection strings
 in settings in the project. If the string in the web.config is not found
 then it falls back to the connection string in the dll. (from settings).
 That's where I discovered my string seems to be an old string. Anyway I have
 gotten it talking to my webhost's database again (they moved the SQL server
 and it stopped working!).



 The problem i'm having now is that on the server i'm trying to deploy my
 app to it's got a similar problem, it can't connect to the database. I wrote
 a command line app to make calls to the same assembly the webservice uses to
 call the database, and it has no problems connecting.

 The connection string in the command's config and the string in the
 web.config is the same. I've tried changing it from (local) to 127.0.0.1to 
 the subnet ip address and all seem to fail. I see no hits on the database
 using SQL profiler. It has to be a connection string issue but I can't see
 it for looking. Any ideas anyone? oh, I've set up my local machine in a
 similar manner and it works (using (local)) so putting that up on the server
 you'd think it would work. Could be a cross domain thing but the webservice
 is working its just the database calls by the webservice are failing.



 thanks!

 Stephen

 p.s. this was the problem I was trying to solve when I hit the other
 problem I posted earlier today. tough day!



 ---
 OzSilverlight.com - to unsubscribe from this list, send a message back to
 the list with 'unsubscribe' as the subject.
 Powered by mailenable.com - List managed by www.readify.net

RE: [OzSilverlight] Linq to sql

2008-08-27 Thread Steven Nagy
Yes its called tight coupling and its a code smell!  J

 

I find it better to always write the code for your DataContext by passing a
connection string, rather than using the parameterless constructor. A quick
FIND in the ENTIRE SOLUTION should help you nail down all cases where the
data context is instantiated without a connection string being passed.

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jordan Knight
Sent: Thursday, 28 August 2008 10:21 AM
To: listserver@ozSilverlight.com
Subject: RE: [OzSilverlight] Linq to sql

 

Yep, but by implementing the pattern below you can ensure the default
constructor always uses the correct connection string - it's a preferential
thing, but I like to encapsulate connection configuration in my data classes
rather than pass connection strings through from my business codeJ

Regards,

Jordan Knight
Readify - Senior Developer

Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia 
M: +61 403 532 404 | E:  mailto:[EMAIL PROTECTED]
[EMAIL PROTECTED] | W:  http://www.readify.net/ www.readify.net

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Steven Nagy
Sent: Thursday, 28 August 2008 10:12 AM
To: listserver@ozSilverlight.com
Subject: RE: [OzSilverlight] Linq to sql

 

 This way you can explicitly control your connection string

 

Or you can just set the connection string to the right one when you
instantiate your data context???

var db = new MainDataDataContext (SomeHelperClass.DefaultConnectionString);

 

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jordan Knight
Sent: Thursday, 28 August 2008 8:37 AM
To: listserver@ozSilverlight.com
Subject: RE: [OzSilverlight] Linq to sql

 

Hi Stephen,

 

You are having a tricky few days J

 

Sometimes LINQ to SQL config issues can arise when you have your LINQ
classes in another assembly...

 

If this is the case you may be able to get around it by following these
steps:

 

. In you LINQ to SQL designer (on the dbml file) - go to Properties
and remove the Connection field.

. This re-creates the LINQ class with a new constructor that wasn't
there before you can utilise to override connection strings

. Create a new cs file to house a partial class:

public partial class MainDataDataContext

{

public MainDataDataContext() :

 
base(System.Configuration.ConfigurationManager.ConnectionStrings[someConnSr
ing].ConnectionString, mappingSource)

{

OnCreated();

}

}

 

MainDataDataContext is the same class that was created by the LINQ designer.
This way you can explicitly control your connection string.

 

 

 

 

Regards,

Jordan Knight
Readify - Senior Developer

Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia 
M: +61 403 532 404 | E:  mailto:[EMAIL PROTECTED]
[EMAIL PROTECTED] | W:  http://www.readify.net/ www.readify.net

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Stephen Price
Sent: Wednesday, 27 August 2008 11:17 PM
To: listserver@ozsilverlight.com
Subject: [OzSilverlight] Linq to sql

 

Hey all,

 

I was having a problem with my WCF web service talking to the database. I'm
using Linq to SQL, and discovered that it stores the connection strings in
settings in the project. If the string in the web.config is not found then
it falls back to the connection string in the dll. (from settings). That's
where I discovered my string seems to be an old string. Anyway I have gotten
it talking to my webhost's database again (they moved the SQL server and it
stopped working!). 

 

The problem i'm having now is that on the server i'm trying to deploy my app
to it's got a similar problem, it can't connect to the database. I wrote a
command line app to make calls to the same assembly the webservice uses to
call the database, and it has no problems connecting. 

The connection string in the command's config and the string in the
web.config is the same. I've tried changing it from (local) to 127.0.0.1 to
the subnet ip address and all seem to fail. I see no hits on the database
using SQL profiler. It has to be a connection string issue but I can't see
it for looking. Any ideas anyone? oh, I've set up my local machine in a
similar manner and it works (using (local)) so putting that up on the server
you'd think it would work. Could be a cross domain thing but the webservice
is working its just the database calls by the webservice are failing.

 

thanks!

Stephen

p.s. this was the problem I was trying to solve when I hit the other problem
I posted earlier today. tough day!

 

---
OzSilverlight.com - to unsubscribe from this list, send a message back to
the list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net 

---
OzSilverlight.com - to unsubscribe from this list, send

RE: [OzSilverlight] Linq to sql

2008-08-27 Thread Steven Nagy
Except you just have to set the connection string to your dev database
anyway when you go to change the LINQ designer (ie add more tables, refresh
the schema, etc).

 

Might as well just leave it in there and instead pass the correct connection
string to the constructor of your Data context.

 

Sorry, a little off topic from SL. J

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Stephen Price
Sent: Thursday, 28 August 2008 10:55 AM
To: listserver@ozsilverlight.com
Subject: Re: [OzSilverlight] Linq to sql

 

Have the Serialization Mode set correctly, I knew about that one. I didn't
realise you could remove the connection string from there. That would
possibly help make things clearer. If I know there's only one connection
string it can use then I'll feel happier it's using it. Will give that a
try...

 

So how does it know which connections string in the Application config file
to use? and which config file? The one belonging to the assembly or the
web.config? My understanding of how this works is that the assembly has a
nameofassembly.config which is used for things such as Unit tests etc, and
then if you deploy it with a webapp and it has a web.config then the
web.config overrides the assembly's config (does it just ignore it or does
it load one value from assembly config then the same value is over written
when the web.config is loaded?)

On Thu, Aug 28, 2008 at 8:34 AM, .net noobie [EMAIL PROTECTED] wrote:

you can also just set it in the properties dialog for the .dbml 

and also note (just in case you did not already know) that you should set
the

Serialization Mode = Unidirectional

if you want to send data from the LinqToSql .dbml via a WCF service to a
Silverlight Application

i attached a pic incase I am not being clear... 






On 8/28/08, Steven Nagy [EMAIL PROTECTED] wrote: 

 This way you can explicitly control your connection string

 

Or you can just set the connection string to the right one when you
instantiate your data context???

var db = new MainDataDataContext (SomeHelperClass.DefaultConnectionString);

 

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jordan Knight
Sent: Thursday, 28 August 2008 8:37 AM
To: listserver@ozSilverlight.com
Subject: RE: [OzSilverlight] Linq to sql

 

Hi Stephen,

 

You are having a tricky few days J

 

Sometimes LINQ to SQL config issues can arise when you have your LINQ
classes in another assembly...

 

If this is the case you may be able to get around it by following these
steps:

 

. In you LINQ to SQL designer (on the dbml file) - go to Properties
and remove the Connection field.

. This re-creates the LINQ class with a new constructor that wasn't
there before you can utilise to override connection strings

. Create a new cs file to house a partial class:

public partial class MainDataDataContext

{

public MainDataDataContext() :

 
base(System.Configuration.ConfigurationManager.ConnectionStrings[someConnSr
ing].ConnectionString, mappingSource)

{

OnCreated();

}

}

 

MainDataDataContext is the same class that was created by the LINQ designer.
This way you can explicitly control your connection string.

 

 

 

 

Regards,

Jordan Knight
Readify - Senior Developer

Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia 
M: +61 403 532 404 | E:  mailto:[EMAIL PROTECTED]
[EMAIL PROTECTED] | W:  http://www.readify.net/ www.readify.net

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Stephen Price
Sent: Wednesday, 27 August 2008 11:17 PM
To: listserver@ozsilverlight.com
Subject: [OzSilverlight] Linq to sql

 

Hey all,

 

I was having a problem with my WCF web service talking to the database. I'm
using Linq to SQL, and discovered that it stores the connection strings in
settings in the project. If the string in the web.config is not found then
it falls back to the connection string in the dll. (from settings). That's
where I discovered my string seems to be an old string. Anyway I have gotten
it talking to my webhost's database again (they moved the SQL server and it
stopped working!). 

 

The problem i'm having now is that on the server i'm trying to deploy my app
to it's got a similar problem, it can't connect to the database. I wrote a
command line app to make calls to the same assembly the webservice uses to
call the database, and it has no problems connecting. 

The connection string in the command's config and the string in the
web.config is the same. I've tried changing it from (local) to 127.0.0.1
http://127.0.0.1/  to the subnet ip address and all seem to fail. I see no
hits on the database using SQL profiler. It has to be a connection string
issue but I can't see it for looking. Any ideas anyone? oh, I've set up my
local machine in a similar manner and it works (using (local)) so putting
that up on the server you'd think it would work. Could be a cross domain
thing but the webservice

Re: [OzSilverlight] Linq to sql

2008-08-27 Thread .net noobie
so basically you have the two modes...

Mode=ConnectionString,  to use the connection string in your .dbml file

or

Mode=WebSettings, it's going to load from the web.config



On 8/28/08, .net noobie [EMAIL PROTECTED] wrote:

 if you navigate to the folder in windows explorer where the .dbml file
 is then open the .dbml file in not pad you will see it is a xml file...

 it has things set in there that tell it where to find and which connection
 string to use

 On 8/28/08, Stephen Price [EMAIL PROTECTED] wrote:

 Have the Serialization Mode set correctly, I knew about that one. I didn't
 realise you could remove the connection string from there. That would
 possibly help make things clearer. If I know there's only one connection
 string it can use then I'll feel happier it's using it. Will give that a
 try...

 So how does it know which connections string in the Application config
 file to use? and which config file? The one belonging to the assembly or the
 web.config? My understanding of how this works is that the assembly has a
 nameofassembly.config which is used for things such as Unit tests etc, and
 then if you deploy it with a webapp and it has a web.config then the
 web.config overrides the assembly's config (does it just ignore it or does
 it load one value from assembly config then the same value is over written
 when the web.config is loaded?)

 On Thu, Aug 28, 2008 at 8:34 AM, .net noobie [EMAIL PROTECTED]wrote:

 you can also just set it in the properties dialog for the .dbml

 and also note (just in case you did not already know) that you should set
 the

 *Serialization Mode* = *Unidirectional*

 if you want to send data from the LinqToSql .dbml via a WCF service to a
 Silverlight Application

 i attached a pic incase I am not being clear...



 On 8/28/08, Steven Nagy [EMAIL PROTECTED] wrote:

  This way you can explicitly control your connection string



 Or you can just set the connection string to the right one when you
 instantiate your data context???

 var db = new MainDataDataContext(SomeHelperClass.DefaultConnectionString);





 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Jordan Knight
 *Sent:* Thursday, 28 August 2008 8:37 AM
 *To:* listserver@ozSilverlight.com
 *Subject:* RE: [OzSilverlight] Linq to sql



 Hi Stephen,



 You are having a tricky few days J



 Sometimes LINQ to SQL config issues can arise when you have your LINQ
 classes in another assembly...



 If this is the case you may be able to get around it by following these
 steps:



 · In you LINQ to SQL designer (on the dbml file) – go to
 Properties and remove the Connection field.

 · This re-creates the LINQ class with a new constructor that
 wasn't there before you can utilise to override connection strings

 · Create a new cs file to house a partial class:

 public partial class MainDataDataContext

 {

 public MainDataDataContext() :

 base(System.Configuration.ConfigurationManager
 .ConnectionStrings[someConnSring].ConnectionString, mappingSource)

 {

 OnCreated();

 }

 }



 MainDataDataContext is the same class that was created by the LINQ
 designer. This way you can explicitly control your connection string.









 Regards,

 *Jordan Knight*
 Readify - Senior Developer

 Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
 M: +61 403 532 404 | E: [EMAIL PROTECTED] | W: www.readify.net



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Stephen Price
 *Sent:* Wednesday, 27 August 2008 11:17 PM
 *To:* listserver@ozsilverlight.com
 *Subject:* [OzSilverlight] Linq to sql



 Hey all,



 I was having a problem with my WCF web service talking to the database.
 I'm using Linq to SQL, and discovered that it stores the connection strings
 in settings in the project. If the string in the web.config is not found
 then it falls back to the connection string in the dll. (from settings).
 That's where I discovered my string seems to be an old string. Anyway I 
 have
 gotten it talking to my webhost's database again (they moved the SQL server
 and it stopped working!).



 The problem i'm having now is that on the server i'm trying to deploy my
 app to it's got a similar problem, it can't connect to the database. I 
 wrote
 a command line app to make calls to the same assembly the webservice uses 
 to
 call the database, and it has no problems connecting.

 The connection string in the command's config and the string in the
 web.config is the same. I've tried changing it from (local) to
 127.0.0.1 to the subnet ip address and all seem to fail. I see no hits
 on the database using SQL profiler. It has to be a connection string issue
 but I can't see it for looking. Any ideas anyone? oh, I've set up my local
 machine in a similar manner and it works (using (local)) so putting that up
 on the server you'd think it would work. Could be a cross domain thing

Re: [OzSilverlight] Linq to sql

2008-08-27 Thread Stephen Price
So which string does it use if you set it to use application config AND
you set a config setting in the dbml designer? I was thinking it uses
web.config in preference.

Anyway, i've gone down the route of setting the connection string in the
constructor of the DataContext partial class, although I can see Steve's
point about passing in the string and not using the default constructor at
all. I'll probably go that way in the end.

This is weird tho. If I press F5 and debug my Silverlight application
(keeping on topic here ;) it can connect to the database. If I publish the
web site to a local website and run it from a browser it CANT connect to the
database. I tried attaching to the process and debugging it but it's not
hitting any of my breakpoints anywhere. Not sure what's up with that. I
guess the good news is I've managed to duplicate the issue locally, should
make it a bit easier I hope.

cheers,
Stephen
On Thu, Aug 28, 2008 at 9:51 AM, .net noobie [EMAIL PROTECTED] wrote:

 so basically you have the two modes...

 Mode=ConnectionString,  to use the connection string in your .dbml file

 or

 Mode=WebSettings, it's going to load from the web.config




 On 8/28/08, .net noobie [EMAIL PROTECTED] wrote:

 if you navigate to the folder in windows explorer where the .dbml file
 is then open the .dbml file in not pad you will see it is a xml file...

 it has things set in there that tell it where to find and which connection
 string to use

 On 8/28/08, Stephen Price [EMAIL PROTECTED] wrote:

  Have the Serialization Mode set correctly, I knew about that one. I
 didn't realise you could remove the connection string from there. That would
 possibly help make things clearer. If I know there's only one connection
 string it can use then I'll feel happier it's using it. Will give that a
 try...

 So how does it know which connections string in the Application config
 file to use? and which config file? The one belonging to the assembly or the
 web.config? My understanding of how this works is that the assembly has a
 nameofassembly.config which is used for things such as Unit tests etc, and
 then if you deploy it with a webapp and it has a web.config then the
 web.config overrides the assembly's config (does it just ignore it or does
 it load one value from assembly config then the same value is over written
 when the web.config is loaded?)

  On Thu, Aug 28, 2008 at 8:34 AM, .net noobie [EMAIL PROTECTED]wrote:

 you can also just set it in the properties dialog for the .dbml

 and also note (just in case you did not already know) that you should
 set the

 *Serialization Mode* = *Unidirectional*

 if you want to send data from the LinqToSql .dbml via a WCF service to a
 Silverlight Application

 i attached a pic incase I am not being clear...



 On 8/28/08, Steven Nagy [EMAIL PROTECTED] wrote:

   This way you can explicitly control your connection string



 Or you can just set the connection string to the right one when you
 instantiate your data context???

 var db = new MainDataDataContext(SomeHelperClass.DefaultConnectionString);





 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Jordan Knight
 *Sent:* Thursday, 28 August 2008 8:37 AM
 *To:* listserver@ozSilverlight.com
 *Subject:* RE: [OzSilverlight] Linq to sql



 Hi Stephen,



 You are having a tricky few days J



 Sometimes LINQ to SQL config issues can arise when you have your LINQ
 classes in another assembly...



 If this is the case you may be able to get around it by following these
 steps:



 · In you LINQ to SQL designer (on the dbml file) – go to
 Properties and remove the Connection field.

 · This re-creates the LINQ class with a new constructor that
 wasn't there before you can utilise to override connection strings

 · Create a new cs file to house a partial class:

 public partial class MainDataDataContext

 {

 public MainDataDataContext() :

 base(System.Configuration.ConfigurationManager
 .ConnectionStrings[someConnSring].ConnectionString, mappingSource)

 {

 OnCreated();

 }

 }



 MainDataDataContext is the same class that was created by the LINQ
 designer. This way you can explicitly control your connection string.









 Regards,

 *Jordan Knight*
 Readify - Senior Developer

 Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 |
 Australia
 M: +61 403 532 404 | E: [EMAIL PROTECTED] | W: www.readify.net



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Stephen Price
 *Sent:* Wednesday, 27 August 2008 11:17 PM
 *To:* listserver@ozsilverlight.com
 *Subject:* [OzSilverlight] Linq to sql



 Hey all,



 I was having a problem with my WCF web service talking to the database.
 I'm using Linq to SQL, and discovered that it stores the connection 
 strings
 in settings in the project. If the string in the web.config is not found
 then it falls back to the connection string in the dll

Re: [OzSilverlight] Linq to sql

2008-08-27 Thread Stephen Price
Good idea, I can see the merits in doing that.

Back to my issue, it seems now that it's related to the url of the endpoint
of the WCF service. I read a post yesterday about this so will try find it
again.

changing the endpoint from localhost:portnumber/service.svc to
localhost/service.svc made it work locally. I need to figure out what the
correct endpoint is for the Test server to work.

Funny how this has gone from a connection string to the endpoint string. I
think I had two issues at the same time.

On Thu, Aug 28, 2008 at 9:47 AM, Steven Nagy [EMAIL PROTECTED] wrote:

  Except you just have to set the connection string to your dev database
 anyway when you go to change the LINQ designer (ie add more tables, refresh
 the schema, etc).



 Might as well just leave it in there and instead pass the correct
 connection string to the constructor of your Data context.



 Sorry, a little off topic from SL. J



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Stephen Price
 *Sent:* Thursday, 28 August 2008 10:55 AM
 *To:* listserver@ozsilverlight.com
 *Subject:* Re: [OzSilverlight] Linq to sql



 Have the Serialization Mode set correctly, I knew about that one. I didn't
 realise you could remove the connection string from there. That would
 possibly help make things clearer. If I know there's only one connection
 string it can use then I'll feel happier it's using it. Will give that a
 try...



 So how does it know which connections string in the Application config file
 to use? and which config file? The one belonging to the assembly or the
 web.config? My understanding of how this works is that the assembly has a
 nameofassembly.config which is used for things such as Unit tests etc, and
 then if you deploy it with a webapp and it has a web.config then the
 web.config overrides the assembly's config (does it just ignore it or does
 it load one value from assembly config then the same value is over written
 when the web.config is loaded?)

 On Thu, Aug 28, 2008 at 8:34 AM, .net noobie [EMAIL PROTECTED]
 wrote:

 you can also just set it in the properties dialog for the .dbml

 and also note (just in case you did not already know) that you should set
 the

 *Serialization Mode* = *Unidirectional*

 if you want to send data from the LinqToSql .dbml via a WCF service to a
 Silverlight Application

 i attached a pic incase I am not being clear...




  On 8/28/08, *Steven Nagy* [EMAIL PROTECTED] wrote:

  This way you can explicitly control your connection string



 Or you can just set the connection string to the right one when you
 instantiate your data context???

 var db = new MainDataDataContext(SomeHelperClass.DefaultConnectionString);





 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Jordan Knight
 *Sent:* Thursday, 28 August 2008 8:37 AM
 *To:* listserver@ozSilverlight.com
 *Subject:* RE: [OzSilverlight] Linq to sql



 Hi Stephen,



 You are having a tricky few days J



 Sometimes LINQ to SQL config issues can arise when you have your LINQ
 classes in another assembly...



 If this is the case you may be able to get around it by following these
 steps:



 · In you LINQ to SQL designer (on the dbml file) – go to
 Properties and remove the Connection field.

 · This re-creates the LINQ class with a new constructor that
 wasn't there before you can utilise to override connection strings

 · Create a new cs file to house a partial class:

 public partial class MainDataDataContext

 {

 public MainDataDataContext() :

 base(System.Configuration.ConfigurationManager
 .ConnectionStrings[someConnSring].ConnectionString, mappingSource)

 {

 OnCreated();

 }

 }



 MainDataDataContext is the same class that was created by the LINQ
 designer. This way you can explicitly control your connection string.









 Regards,

 *Jordan Knight*
 Readify - Senior Developer

 Suite 206 Nolan Tower | 29 Rakaia Way | Docklands | VIC 3008 | Australia
 M: +61 403 532 404 | E: [EMAIL PROTECTED] | W: www.readify.net



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Stephen Price
 *Sent:* Wednesday, 27 August 2008 11:17 PM
 *To:* listserver@ozsilverlight.com
 *Subject:* [OzSilverlight] Linq to sql



 Hey all,



 I was having a problem with my WCF web service talking to the database. I'm
 using Linq to SQL, and discovered that it stores the connection strings in
 settings in the project. If the string in the web.config is not found then
 it falls back to the connection string in the dll. (from settings). That's
 where I discovered my string seems to be an old string. Anyway I have gotten
 it talking to my webhost's database again (they moved the SQL server and it
 stopped working!).



 The problem i'm having now is that on the server i'm trying to deploy my
 app to it's got a similar problem, it can't connect to the database. I wrote
 a command line app to make calls