WCF/WF - how to give a reference of connection string in wcf web services.

Asked By harsh shah on 23-Nov-10 03:24 AM
hi All,

i have create a one wcf web services. now i want to use my connection string in wcf web services for database trigerring.

so what i have to do for that.

asap give me a reply.

Thanx.
Regards,

Harsh Shah
Reena Jain replied to harsh shah on 23-Nov-10 04:47 AM
hi harsh

  • In web.config of webservice you have to put a connection string and used that to access db in webservice itself. Access that connstring like;
  • System.Configuration.ConfigurationManager.ConnectionStrings.Item("DatabaseConnection").ConnectionString
  • Use it in ur connection n do all operations here.
  • Then add webreference to ur appl and access all functionality from there only.
reference the System.Configuation Namespace
here is a good link for this
http://msdn.microsoft.com/en-us/library/ff650091.aspx
hope this will help you

harsh shah replied to Reena Jain on 23-Nov-10 06:09 AM
Hi Reena,

Thanx
i have try this but not working.
i have add a connection string in to the web config.
Now i want to give a connection string reference in to the wcf webservices class files.

System.Configuration.ConfigurationManager.ConnectionStrings.Item(
"DatabaseConnection").ConnectionString


in web services class file not accept this type. in webservice cs file not accept configuration manager.
it's only possible to .aspx.cs file and .cs file but not possible to define configurationmanager in webservice class file.

u know any other way then plz infrom me.

Regards,

Harsh Shah