Connection String Help


Author
Message
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
Not only am I new to StrataFrame AND Web Dev AND VS - but also to SQL Blush...needing a little help on the connection string.  I've copied the connection string from one of the wizards - but getting this error upon adding it to my global.asax - "Unrecognized escape sequence."

Here's what's in the Global.asax:

DataLayer.DataSources.Add(new SqlDataSourceItem("", "Data Source=SQLLR01\SQLLR01;Initial Catalog=PTPlusData;Integrated Security=True"));

Thanks again for helping the new guy out!

HB


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Since this a web application, you will really want to use a user versus integrated security.  That would be one problem, but in either case, an example of each is below. Smile

New SqlDataSourceItem("","server=MyServer;user id=sa;password=Mypassword;database=MyDatabase;")

or

New SqlDataSourceItem("","server=MyServer;Integrated Security=SSPI;database=MyDatabase;")

Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
I've changed it to this:

DataLayer.DataSources.Add(new SqlDataSourceItem("", "server=SQLLR01;Integrated Security=SSPI;database=PTPlusData"));

and get the error saying a connection could not be established.

So...I created a WinForms app - added the BO - added a textbox.  When the app started - got the connection manager.  Filled in all the appropriate items and was able to connect and save data.  I went to the program.cs in that app and tried to manually insert the connection string as above - got the same error as the above caused.

Is there a way to see what the Connection Manager used? I figure I can copy that...

Thanks again - HB


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
That is what I was saying, unless you setup the IUSER_ account for the OS as an allowed user for the SQL Server, then you will not be able to authenticate with Integrated Security.  You will want to use an explicit user name, not integrated security.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
If you have a named instance that you are referencing in the connection string then it will need to look like this:

DataLayer.DataSources.Add(new SqlDataSourceItem("Security", "Data Source=Server\\Instance;Initial Catalog=MySecurityDB;User ID=user;Password=pwd;Asynchronous Processing=True"));

Notice the "\\" which will allows the code to recognize the "\" character.

Hope that helps,
Bill

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Just FWI...SF automatically adds the Asynchronous processing tag for you as needed.  Since the DataLayer can save on multiple threads, this is a core level functionality of the framework.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Just FWI...

New acronym? Tongue

I'll knock those off, then.  Thanks!

Bill

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Oops...that is what fast typing get you...speed kills BigGrin
Howard Bennett
Howard Bennett
StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)StrataFrame Novice (65 reputation)
Group: Forum Members
Posts: 57, Visits: 496
Bill and Trent,

Thanks - I've changed it to look like this:

DataLayer.DataSources.Add(new SqlDataSourceItem("", "Data Source=SQLLR01\\SQLLR01;Initial Catalog=PTPlusData;Integrated Security=SSPI"));

Seems to work now.

But...a question on the user name...help me understand how this works.  I was thinking the webserver would be the one logging into the SQL Server.  As such, I was thinking I could use the Windows security instead of a user name/password scenario.  Why is it that I need a user name instead?  (I'm not arguing with you here - just wanting to understand - I really appreciate the help!!!)

HB


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Hey HB!

It has been a while since I worked on a web application, but I think the use of an ID/password in the connection string has something to do with connection pooling.  Others will have to chime in here to flesh this out a bit.  Since the web server is client agnostic, I think the integrated security option versus security declarations is six of one, half dozen of another.  The web server should always be connecting to the data server under the same security context, so it may be better to specify that in the connection string.  The web server's security context, then, does not need to be directly involved.  The application itself maintains control.

Just rambling, here.  I doubt that my explanation is very clear. 

I need more coffee.  Hehe

Bill

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search