Refer this URL for all types of connection strings,
http://www.connectionstrings.com
Search all source files that have something to do with database.
Adding a new connection string to the Web.config File.
Web.config:
<connectionStrings>
<add name="SomeConnection" connectionString="Data
Source=VCNSQL82\I82;Initial Catalog=ibr1;UserID=ibr12;Password=ibr12"
providerName="System.Data.SqlClient" />
</connectionStrings>
// c# syntax
// Retrieve connection string from the Web.config file
string strConnectionString =
System.Configuration.ConfigurationManager.ConnectionStrings["SomeConnection"].ConnectionString;
// Use the connection...
using (SqlConnection connection = new
SqlConnection(strConnectionString))
{
SqlCommand command = connection.CreateCommand();
// open the connection
connection.Open();
// some code
// .....
}
Read more from here:
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx
-ste...@hellsinki-
On Sep 21, 6:51 am, May0rDav3 <[email protected]> wrote:
> If you have access to the web.config and app.config files, I would be
> happy to take a look at them to at least try to determine how it is
> (or rather was) connecting to the database. Please feel free to
> change any identifying values prior to emailing if you wish.
>
> On Sep 19, 10:13 pm, OccasionalFlyer <[email protected]> wrote:
>
> > Well, however this might sound, I was asked to take over
> > administration of the site so that he previous administrator would
> > have time for a large research project/book. I was told I'd be adding
> > HTML, tweaking web pages and such. My web programming knowledge is in
> > technologies other than ASP.NET. I've done reading in a couple of
> > ASP.NET programming books but I didn't get what I need to do here I
> > guess. I've looked through web.config., app.config, and the site's
> > BIN directory and found nothing. All I know is that the ISP says we
> > are still using the legacy MSSQL server and need a new connection
> > string. I don't know where to find that. So I cannot tell you how
> > the site currently accesses the database. Thanks.
>
> > Ken
>
> > On Sep 16, 1:08 am, Cerebrus <[email protected]> wrote:
>
> > > Ken,
>
> > > What tag you put the connection string in, is irrelevant, because we
> > > do not know how you are retrieving the connection string. If your
> > > existing code picks it from an appSettings element, then you can use
> > > that. If it picks it from a ConnectionStrings element, then use what
> > > they have suggested. You're not providing us enough details to be able
> > > to troubleshoot the problem.
>
> > > I think you need someone more experienced with this stuff to take a
> > > look at the existing setup. I could take a look if you would contact
> > > me on my mail with FTP details of the server.
>
> > > On Sep 16, 11:06 am, OccasionalFlyer <[email protected]> wrote:
>
> > > > My web site broke last week and my ISP claims it is because I need a
> > > > connection string in my web.config. Of course, the fact that the site
> > > > has function for years without that seems irrelevant to them, but I
> > > > digress. I have looked at a _bunch_ of examples from a Google search
> > > > of how to do this but none of them has given me the info I need. The
> > > > ISP said to add this:
>
> > > > connectionString="Data Source=VCNSQL82\I82;Initial Catalog=ibr1;User
> > > > ID=ibr12;Password=ibr12" providerName="System.Data.SqlClient"
>
> > > > However, from the examples, I see that this needs to be inside
> > > > <appSettings>
>
> > > > </appSettings>
>
> > > > Beyond that, however, I see all sorts of different things to do and no
> > > > explanation of the exact details, like how to pick a name for a
> > > > connection string. Can someone help me out with what I need to insert
> > > > into the above connectionString for proper syntax?
>
> > > > Also, the ISP said that after I do this, I need to compile the
> > > > site. I have no idea how to do that. Shouldn't, however, the XML of
> > > > web.config be read on the fly, not compiled? Thanks.
>
> > > > Ken