Dofactory.com
Dofactory.com
 Back to list
Views:   3.8K
Replies:  1
Archived

How to set the connectionstring

I am curious how to setup the connection string in SPARK. I tried..
I'm missing something? pls help


Archie Jocson, Jul 17, 2015
Reply 1
Hello Archie:

Look at the Art shop example. 

The file Data.cs is where your connection string is specified. 
In the example it is "Art", but you can name it anything you like as along as it matches the connectionstring name in web.config. 

SPARK uses a naming convention.
Suppose your project is named 'Work'. (a short name is best).

Then: 
  • You will probably have a database named Work.
  • You would have a 'Work' connectionstring name in web.config.
  • Then you will create a WorkDb where you hardcode the "Work" connectionstring name.
  • WorkDb is used by WorkContext, which is then used in your own controller code. 

Essentially replace all instance of the word 'Art' with 'Work' (or whatever your name is. 

Here is your Data.cs file where the connectionstring name is set:
public partial class WorkDb : Db
{
    public WorkDb() : base("Work") {}
}

That will take care of it.
Jack
 
Jack Poorte, Jul 18, 2015
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.