當我嘗試在C#中編寫到我的數據庫的應用程序連接時,我在Visual Studio 2005中成功構建應用程序,但是當我在調試器中運行該網站時,出現錯誤:Asp.Net應用程序數據庫連接問題
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 118.
下面是給錯誤的連接代碼:我有我的web.config正確寫入連接字符串
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Server"].ConnectionString);
,什麼這意味着遠程文件,以便即時無言以對。林不知道如果我失去了什麼。任何幫助讚賞。這裏是我可能幫助的部分的全部代碼:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;
using System.Data.SqlClient;
public partial class RateAnalyzerPage: System.Web.UI.Page
{
protected void Search_Click(object sender, EventArgs e)
{
string IDnumber = mechantNumber.Text;
string selectSQL = "SELECT FROM Authors Where MID='"+ IDnumber +"'";
// SqlConnection con = new SqlConnection(@"Server=");
//SqlConnection con = new SqlConnection();
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Server"].ConnectionString);
SqlDataReader reader;
try
{
con.Open();
SqlCommand cmd = new SqlCommand(selectSQL, con);
reader = cmd.ExecuteReader();
while (reader.Read())
{
QualVol.Text = reader["TotalVolume"].ToString();
}
reader.Close();
}
catch (Exception err)
{
}
finally
{
con.Close();
}
}
}
讓我知道是否缺少一些有用的數據。
繼承人的連接字符串:
什麼行給出了錯誤,當您打開連接?你可以發佈你的web.config connectionStrings部分? – 2012-07-24 21:09:27
你需要發佈你的''connectionStrings'部分。配置文件;這是最有可能發生錯誤的地方 – GolfWolf 2012-07-24 21:09:45
'code' \t \t connectionStrings>'code' –
2012-07-24 21:20:28