Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
This is my connection String
XML
<connectionstrings>

    <add name="ConnectionString" connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=<br mode=" hold=" />         |DataDirectory|\FusionChartsDB.mdf;Integrated Security=True;User Instance=True">
         <providerName="System.Data.SqlClient" />
  
</add>
</connectionstrings>


and my Database is located at my SQL Server management studio r2,
and the database is in DBfolder from Server explorer

My Deafult.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace InfoSoftGlobal.BluePrintApp.FC_ASP
{
///
/// Summary description for _default.
///

public class _default : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if ((Request.Form["Header1:animate"] == null ||
Request.Form["Header1:animate"].ToString().Length == 0) &&
Session["animation"] == null)
Session["animation"] = "1";
else if (Request.Form["Header1:animate"] != null)
Session["animation"] = Request.Form["Header1:animate"].ToString();

((UserControls.header)this.FindControl("Header1")).ShowSelection();

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

Im using the Fusioncharts Sample code and it said that

FusionCharts Blueprint Application - C# (ASP.NET) + MS Access / SQL version
==================================================================

This demo application shows the capabilities of FusionCharts by integrating
it with C# (ASP.NET) and Access/SQL. The databases are contained in FusionChartsDB folder.
You'll find the Access MDB file and the SQL Database generation script.

Based on what you intend to use, change the data connection string in Web.config.

After that, run App/Default.aspx to view the application. Make sure you copy
all the files from App folder, keeping the folder structure intact.

PLEASE NOTE THAT THIS DEMO APPLICATION JUST USES A HANDFUL OF CHARTS
FROM FUSIONCHARTS SUITE FOR DEMO PURPOSE. FUSIONCHARTS OFFERS A LOT
MORE VARIETY OF CHARTS, WHICH IS PRESENT IN EVALUATION DOWNLOAD.

Troubleshooting
==================================================================
If for some reason, you do not see the charts, make sure you've
Adobe Flash Player 8 (or above) installed on your machine.

Support Information
==================================================================
Website: http://www.InfoSoftGlobal.com/FusionCharts
Email: support@infosoftglobal.com

Im New to Asp.net
Posted
Updated 2-Feb-14 23:43pm
v4
Comments
King Fisher 3-Feb-14 7:48am    
if you solved this.update it

Try something like

XML
<connectionStrings>
   <add name="ConnString" connectionString="Data Source=localhost;Initial Catalog=YourDBName;Integrated Security=True;" providerName="System.Data.SqlClient" />
 </connectionStrings>



Refer below link and modify accordingly as needed.

http://www.connectionstrings.com/sql-server-2008/[^]
 
Share this answer
 
If you simply want a connection string . place a gridview control on webpage & add the new datasouce, select the database you wanted to connect through code.
You will get the connection string from grdview properties.
 
Share this answer
 
Comments
Member 10533469 3-Feb-14 5:40am    
The ConnectionString property has not been initialized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: The ConnectionString property has not been initialized.]
you can try, I hope this is help full for you.
XML
<add name="_MyCon" connectionstring="Data Source=SystemName or you can used .[Dot];Initial Catalog=your DataBase Name ;Integrated Security=True">
   providerName="System.Data.SqlClient" />

</add>


and you can used in C# like this.
C#
 public SqlConnection _con;
_con = new SqlConnection(ConfigurationManager.ConnectionStrings["_MyCon"].ConnectionString);


for any query hit to reply.

Happy coding
 
Share this answer
 
In the web.config file add connection string as following

XML
<connectionStrings>
        <add name="con" connectionString="Data Source=.\sqlexpress;Initial Catalog=dbName;Integrated Security=True ; Pooling=False;"/>
    </connectionStrings>



and in the code behind u can access the connection string as

string connStr = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
 
Share this answer
 
You can change you web config file for connection based on your requirement:

Standard Security
HTML
Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;


Trusted Connection
HTML
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;


Connection To SqlServer instance
HTML
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;
 
Share this answer
 
Hi,
<connectionstrings>
		<add name="ConnectionString" connectionstring="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|FusionChartsDB.mdf;User Instance=true" providername="System.Data.SqlClient" />
</connectionstrings>
 
Share this answer
 
You can use the appSettings Tag in web.config for this purpose like below.

XML
<appSettings>
    <add key="dbStr" value="Server=local;Database=YourDBName;user id=sa ;password=SQLPassword"/>
</appSettings>


and to get/use it in application you can do something like below.

C#
string connectionString = System.Configuration.ConfigurationManager.AppSettings["dbStr"].ToString(); 


Hope it will help. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900