过去一周我一直坚持这一点,如果你们能提供帮助,我会很高兴。
我正在使用 MS Visual Studio 2010 开发 vb。我目前在名为“app_data”的 asp.net 文件夹下有一个数据库。
我正在尝试通过 web.config 文件执行 connectionString 命令。
网络配置:
<connectionStrings>
<add name="mysqlcon" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\public.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
主要代码:
Dim a As String = ConfigurationManager.ConnectionStrings("mysqlcon").ConnectionString
Dim conn As New MySqlConnection(a)
Try
conn.Open()
MsgBox("good")
conn.Close()
Catch ex As MySqlException
MsgBox(ex.Message)
Finally
conn.Dispose()
End Try
我收到以下错误(第 10 行突出显示):
Server Error in '/MP' Application.
Keyword not supported.
Parameter name: attachdbfilename
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.ArgumentException: Keyword not supported.
Parameter name: attachdbfilename
Source Error:
Line 8: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 9: Dim a As String = ConfigurationManager.ConnectionStrings("mysqlcon").ConnectionString
Line 10: Dim conn As New MySqlConnection(a)
Line 11:
Line 12:
Stack Trace:
[ArgumentException: Keyword not supported.
Parameter name: attachdbfilename]
MySql.Data.MySqlClient.MySqlConnectionStringBuilder.ValidateKeyword(String keyword) +108
MySql.Data.MySqlClient.MySqlConnectionStringBuilder.set_Item(String keyword, Object value) +18
System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) +185
MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString(String value) +289
MySql.Data.MySqlClient.MySqlConnection..ctor(String connectionString) +26
test.Button1_Click(Object sender, EventArgs e) in C:\Users\God\Desktop\VB\MP\test.aspx.vb:10
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
如果你们能提供帮助会很高兴。