Re: connect from webservice

Tech-Archive recommends: Fix windows errors by optimizing your registry




in web.config:

<appSettings>
<add key="ConnectionString" value="Data Source=MyServer;Initial
Catalog=AdventureWorks;User Id=MyUser;Password=MyPassword;"/>
</appSettings>

in the web service:
string cnString =
ConfigurationManager.AppSettings.Get("ConnectionString");

Roman

--
Roman Rehak
http://sqlblog.com/blogs/roman_rehak



"wendld" <GenieLifts@xxxxxxxxxxxxxx> wrote in message
news:D1B8082F-16ED-47B7-9FD8-C5A1EBF26DED@xxxxxxxxxxxxxxxx
This is my first attempt at pulling in the connection string from the
machine.config. Windows Authentication is not an option since the database
and webservers are on different domains and a DMZ is in use. I currently
have
the SSL encryption on, but have not encrypted the actually value in the
config file (yet). That is the next step after I get the programs working
this way.

"Roman Rehak" wrote:

It's not any different than connecting from an ASP.NET page so if you
know
how to do that, you should be all set. It's not a good practice to place
passwords in a config file so you should look into using Windows
authentication or at the very least encrypt the password in the config
file.

Roman

--
Roman Rehak
http://sqlblog.com/blogs/roman_rehak


"wendld" <GenieLifts@xxxxxxxxxxxxxx> wrote in message
news:7A009E7B-EE22-4FFC-8B4B-FE870659D985@xxxxxxxxxxxxxxxx
I have a webservice I am creating. I am needing to connect to a SQL
server
on
a different machine using SQL authetication. I have the connection
string
located in the machine.config. Could somebody give me a sample of how
to
use
that connection string to connect to the database from inside a
webservice.





.



Relevant Pages

  • Re: A little Rolodex [revised]
    ... including alpha sort and searching for any embedded string, ... In this application, a database is a directory, ... you may optionally provide any alternate UCASE program, ... NN -> first store NN as key length ...
    (comp.sys.hp48)
  • Re: return multiple rows from sql statement
    ... strings from input values is almost certainly a safe path to SQL ... Also, being a MySQL function, it knows what MySQL needs or uses. ... All characters that are entered in the fields make their way into the database unaltered. ... The insert of what surprisinlgly was NOT a syntax error, but a string called "mysql_insert_id" into an integer field resulted in the value zero being put in. ...
    (comp.lang.php)
  • Re: Code to delete/unlink Linked tables
    ... Public intLinkODBCTables As Variant, intLinkDB2Tables As Variant ... Public strLinkBackendDB As String, strLinkDSNname As String, strLinkLibName ... ' MsgBox "This database is in MDE format...I will delete/recreate ODBC ... Public Sub fncLinkDB2Table() ...
    (microsoft.public.access.modulesdaovba)
  • Re: Establish connection with and transferring data to Access
    ... The specific problem with your code is that you need to quote string ... Dim vConnection As New ADODB.Connection ... Experiment with the object model or check the documentation for the ... Doug's code opens and writes to an existing database. ...
    (microsoft.public.word.vba.general)
  • Re: Invalid variant type conversion
    ... because within regular programming, there would be no agreement upon what ... applications built by standard Delphi controls, ... NULL is the same as "" in a database. ... >> The empty string tells it all. ...
    (comp.lang.pascal.delphi.misc)