如何在Web配置中配置连接字符串? [英] How to Configure the Connection String in Web Config?

查看:137
本文介绍了如何在Web配置中配置连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的连接字符串

This is my connection String

<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>





我的数据库位于我的SQL Server管理studio r2,

,数据库在服务器资源管理器的DBfolder中



我的Deafult.cs

使用系统;

使用System.Collections;

使用System.ComponentModel;

使用System.Data;

使用System .Drawing;

使用System.Web;

使用System.Web.SessionState;

使用Syste m.Web.UI;

使用System.Web.UI.WebControls;

使用System.Web.UI.HtmlControls;



命名空间InfoSoftGlobal.BluePrintApp.FC_ASP

{

///< summary>

///摘要描述_default。

///

公共类_default:System.Web.UI.Page

{

private void Page_Load(object sender,System.EventArgs e)

{

//将用户代码置于此处初始化页面

if((请求.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表单设计器生成的代码

覆盖protected void OnInit(EventArgs e)

{

//

// CODEGEN:ASP.NET Web窗体设计器需要此调用。

//

InitializeComponent();

base.OnInit(e);

}



///< summary>

/// Designer支持所需的方法 - 不要使用代码编辑器修改

///此方法的内容。

///

private void InitializeComponent()

{

this.Load + = new System.EventHandler(this.Page_Load);



}

#endregion

}

}



我使用的是Fusioncharts示例代码,它表示



FusionCharts蓝图应用程序 - C#(ASP.NET)+ MS Access / SQL版

============================================== ==================== <无线电通信/>


这个演示应用程序通过将它与C#(ASP.NET)和Access / SQL集成来展示FusionCharts的功能。数据库包含在FusionChartsDB文件夹中。

您将找到Access MDB文件和SQL数据库生成脚本。



基于什么您打算使用,更改Web.config中的数据连接字符串。



之后,运行App / Default.aspx查看应用程序。确保从App文件夹中复制

所有文件,保持文件夹结构不变。



请注意,此演示应用程序只能使用A很多照片

来自FUSIONCHARTS SUITE的DEMO用途。 FUSIONCHARTS提供了很多

更多种类的图表,在评估中显示下载。



故障排除

= ================================================== ===============

如果由于某种原因,你没有看到图表,请确保你已经支持
Adob​​e Flash您的机器上安装了玩家8(或以上)。



支持信息

============= ================================================== ===

网站:http://www.InfoSoftGlobal.com/FusionCharts

电子邮件:support@infosoftglobal.com



我是Asp.net的新手



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>
/// 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);
}

/// <summary>
/// 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

推荐答案

尝试

http://www.connectionstrings.com/store-connection-string-in-webconfig/ [ ^ ]

如何在Web Config中添加连接字符串(VS2010 Ultimate) [ ^ ]

http://msdn.microsoft.com /en-us/library/ms178411.aspx [ ^ ]
Try
http://www.connectionstrings.com/store-connection-string-in-webconfig/[^]
How to add Connection String in Web Config (VS2010 Ultimate)[^]
http://msdn.microsoft.com/en-us/library/ms178411.aspx[^]


尝试类似



Try something like

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







请参阅以下链接并根据需要进行相应修改。



< a href =http://www.connectionstrings.com/sql-server-2008/> http://www.connectionstrings.com/sql-server-2008/ [ ^ ]


如果您只是想要一个连接字符串。在网页上放置一个gridview控件并添加新数据,选择你想通过代码连接的数据库。

你将从grdview属性中获取连接字符串。
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.


这篇关于如何在Web配置中配置连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆