ADO.NET :: Passing ConnectionString To DLL?
Nov 15, 2010
I want to know how to pass connection string to my .dll file. I have created one Class Library(dll) now i am using the dll of that in my application. My application is going to deploy on client side so he will going to change the connection string. Now iwant to know how will i directly access the connection string from web.config to my dll. With that i also want to know how will i pass parameters to my dll. I have already tried but it is giving me an error:the remote server returned an error 500 internal server error. Class Library Code:
[Code]....
Web Form Code: where i am using the object of my dll
[Code]....
View 2 Replies
Similar Messages:
Jan 2, 2011
I have a connectionstring in my web.config <add name="HeimkinoVerbindungszeichenfolge1" connectionString="Data Source=SERVER;Initial Catalog=Heimkino;Persist Security Info=True;User ID=sa;Password=*******;"providerName="System.Data.SqlClient" />
This itself is working when using eg the SQLDataSource for a Gridview or similar.
Now I need to access this DB with different scripts and work with that database.
Eg I need to run this comand in a page_load against the DB
[Code]....
to remove old events from the database
For other pages I need something like
[Code]....
for some userauthentication things this should just create a recordset I can work with then.
Is there a way to realize this using the connectionstring in the web.config (and if so, How???)
If this will not work, how can I run such queries?
View 10 Replies
May 21, 2010
is there any method to get the database name from connectionString?
View 1 Replies
Oct 26, 2010
I have a website about to go live. I'm wondering what I should be doing about the connectionstring in the web.config. Do I obfuscate it and it so how?
View 3 Replies
Aug 24, 2010
i'm working on already built asp.net webapplication. in the web.config for connectionString section i have seen this
<add name="MyConnectionString" connectionString="3abcde12n3kd03kldwqaswe45tdw4fo23003ld3ddfot0lkdpe2d" providerName="System.Data.SqlClient"/>
can anyone tell me on how this encryption done? i know the standard way of encrypting using aspnetregiis.exe which replaces the entire connnectionString section of the web.config.
View 4 Replies
Nov 16, 2010
I have an MVC2 .NET 4.0 app, hosted on TFS 2008 (soon to be TFS 2010) that uses connection strings in web.config to connect to a database on another server. I need to encrypt these connection strings.
As I understand it, I can use aspnet_regiis.exe to encrypt the connectionstring portion of the web.config file, but I have to do it on the deployment machine because the encryption uses the machine name to generate the encryption key.
Now, it seems to me that this represents a problem - every time I deploy my code to the dev server won't it overwrite the web.config file, and need to be re-encrypted? This sort of manual process seems kludgy.
Is my understanding about needing to re-encrypt after deployment correct? If so, is there some way to automate this process? I don't want to forget this or get a new team member who doesn't know the process and have the connectionstring exposed to the world.
View 1 Replies
Jun 16, 2010
in one of the application i have been reffering connection string is stored in appsettings! till now i have been storeing the connection in <connectionstring/> element. But, what is the correct way?
So my quetion is, What is the differences between <connectionstring> and <appsettings> in web.config, are there any specific reason why i should or should not be storing connection string in appsettings? Are there any rules / guidlines provided to follow? Or is this completely the choice of the developer?
View 4 Replies
Dec 23, 2010
Trying to do something like
<%$ ConnectionStrings: AppSettings:ENVIRONMENT %>
Is there a way?
View 2 Replies
Dec 3, 2010
i have a class library and i want to use it in difrent web form application.
i created a linq data class and i drag and drop the table of my local database in it.
now i want to use this class library in my web form application with a database in server with difrent database name but with same tables and also the connectionString Name is the same.
in my class library i call myDataContax("MyConnectionStringName")
my question is when i use a connectionstring with the same connectionString Name as my Class library ConentionString Name but with difrent database name it will work or not?
View 6 Replies
Aug 12, 2010
In 3 tier architecture where to keep connection string? I have presentation layer ( webapplication) and BAL Layer ( class lib) and DAL (class lib).intially i kept in web.config which is in presentation layer....is it correct?should i keep a app.config file in DAL layer and keep my connection string in that?Where to keep connection string ?
View 1 Replies
Nov 5, 2010
I just deployed my database to my remote server. I am trying to create a connectionstring to the remote server and it won't work. I am using godaddy. I kept having this message: could not establish a connection to the database. Here is the connectionstring for the local server:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
[code]...
View 3 Replies
Sep 18, 2010
My website has to connect to a hosted SQL Server database. The connectiostring, incluing username and password, is stored in the web config file.I have two questions.The first is that everything I read says this must be encrypted so that it cannot be read and used by others. Well, how would that happen. My understanding of ASP.net is that all the work is carried out on the hosted server and the rendered page is then delivered to the user. How would a user be able to view my connectionstring.Secondly, I have used some msdn vb.net code to encrypt the connection string in the web config file. Following on from the first question, how can I confirm that the encryption is intact on the published web.config file.
View 7 Replies
Sep 4, 2010
I have a class library that contains a valid connectionString inside the app.config. Inside that class library I want to use it with
ConfigurationManager.ConnectionStrings["NAME"].ConnectionString
My ASP.net 4.0 framework application references that DDL and retrieves data from it. I want create a Entity Framework 4 DataContext within my DDL with the ConnectionString from the App.config. (I do not want to pass the connectionString from my ASP.net application in every single method. (I'm using ObjectDataSources))
However, this line inside my DLL throws a NullReferenceException.
ConfigurationManager.ConnectionStrings["NAME"].ConnectionString
View 2 Replies
Aug 15, 2010
SqlConnection conn = new SqlConnection("Persist Security Info=True;Data Source="+txtdatasource.Text+";database="+txtDBName.Text+"; User ID="+txtDBUsername.Text+";password="+txtDBPass.Text);
conn.Open();
SqlCommand cmd =new SqlCommand("SELECT [ItemCode],[ClientDescription] FROM ["+txtDBName.Text+"].[dbo].[Bookings]");
cmd.ExecuteNonQuery();
This gets the folowing error ExecuteNonQuery: Connection property has not been initialized. i know it connects to the database
View 2 Replies
Apr 5, 2010
i have some websites and one part of all websites is the same and it work with dataset i got an ide to creat a code projrct to handel that part and i use it in all websites the problem is the websites not use the same connectionstring but the connectionstring name can be same. i need to set this code project to read the connectiostring from the website web.config file.
View 6 Replies
Oct 25, 2010
how to connect to a CSV file in ASP.net MVC?
View 1 Replies
Nov 1, 2010
I am developing a web application in Visualt Studio 2008. I have a data access layer that is automatically generated using Visual Studio. After publising my site to IIS and tested it for several hours, two exceptions occured:
[Code]....
The connection string is stored in the data access layer in Properties.Settings and has not changed.Does anyone have a clue why these exceptions occur and how i can avoid them?
View 1 Replies
Jun 5, 2010
I am not able to use
String connectionString = ConfigurationManager.ConnectionStrings["DevBackup"].ConnectionString;
I am getting error 'The name 'ConfigurationManager' does not exist in the current context' I have used namespaces
using System.Data.SqlClient;
using System.Data.Sql;
what should be done..?
View 3 Replies
Sep 10, 2010
n my ASP.NET application, I have a sqlclient connectionstring in my web.config file, What is the recommended timeout setting for production environment? Default is 15 seconds.My web farm and database cluster are on the same switch, so there should not be much latency.
View 3 Replies
Jan 17, 2011
I have some Class A, which is data-layer in my web-application, and I'm using A's methods to accomplish Db operations. It looks like this.
[code]...
In case when my .aspx page calls 2 methods of class A during the postback, my page throws
"The ConnectionString property has not been initialized" exception for second method call.
I tried to put _sqlcon initialization into constructor, but it still throws exception.
View 5 Replies
Mar 23, 2011
I'm creating a multi-tenant Asp.Net MVC 3 Web app, and using EF4.1 code first for the db model.For development I'm happy to use SqlServerCE in App_Data, and for production this will move to Sql Server 2008.
Say my context is called "MyModels", by default code-first looks for a connection string called "MyModels" in Web.config. This can be told to use a file in App_Data or changed to access a database in SQL2008. All fine so far.
But because of multi-tenancy, I'd like the SqlServerCE filename to match the unique id of the tenant (so App_Data would have "client_x.sdf", "client_y.sdf"; Sql Server 2008 would have separate databases). I can't work out how to direct to these different databases.
I've tried MyModels inheriting from DbContext and supplying a connection string (using a 'placeholder' conn string in Web.config and replacing "{clientId}" with the unique id), and I've also tried setting the connection string in the MyModels constructor:
base.Database.Connection.ConnectionString = xxx;
but this never seems to work. I always get the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
( it's not yet 'configured' to use SqlServerCE, and so is trying to connect to Sql Server)
Tracing the code, Database.Connection.ConnectionString hasn't been read from Web.config at this point, so I can't search and replace that, and, possibly, it's getting overwritten by the 'placeholder' conn string later in the pipeline.I reckon this must be quite straightforward and I just can't find the 'hook'.
View 2 Replies
Feb 4, 2011
how can i encrpt database password and store to Visual Studio's connectionString areaalso, i would like to know how can i set all config in config file and how the program can read.
View 2 Replies
Jul 27, 2010
I am in trouble writing connectionstring in app.config. Actually database name contains space in its name. following is the connectionstring i want to put in app.config. but when i do the same it gives me error. how to solve this problem ?
<add name="Connection" connectionString="Driver={Microsoft Access Driver (*.mdb)};Dbq=C:Program FilesInsigniaTime & Attendence.mdb;Uid=;Pwd=admin;" />
here, database is access db having name as 'Time & Attendence.mdb'
View 4 Replies
Aug 15, 2010
can anybody tell me how to show how long your connectionstring has been connected to the database?
View 4 Replies
Sep 13, 2010
I have 2 connection strings in my web.config file, and I would like to select which one to use, from code.Currently I have this:
asp:SqlDataSource
ID="SqlDataSourceDelegateServices"
runat="server"
[code]...
View 3 Replies