這是我的app.config文件看起來像:如何將應用程序名稱添加到<appSettings />?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Application Name" value="/MyApplication" />
</appSettings>
<connectionStrings>
<add name="frmStartup.My.MySettings.HDIMembershipProviderConnectionString"
connectionString="Data Source=.\sqlexpress;Initial Catalog=HDIMembershipProvider;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<membership defaultProvider="HDIMembershipProvider">
<providers>
<clear/>
<add name="HDIMembershipProvider" type="MyApplication.HDIMembershipProvider, MyApplication"/>
</providers>
</membership>
</system.web>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
</configuration>
我試圖用HDI會員供應商,這是我的用戶表結構:
在我最近的問題問hereOded
幫我解決了這個問題,我重新修改了它,並在我的數據庫結構中有一個ApplicationName列,我需要指定它(因爲它不應該是空值)
現在我需要添加我的應用程序名稱默認情況下進入數據庫,因爲我們這樣做的web.config。
這就是我的意思。
我需要的是所有MyApplication添加到我的app.config文件。
那麼我該怎麼做?
這是我正在試圖進入用戶的詳細情況數據庫,但它不enetering單個值
Try
Dim connectionString As String = "Data Source=.\sqlexpress;Initial Catalog=HDIMembershipProvider;Integrated Security=True"
Using cn As New SqlConnection(connectionString)
cn.Open()
Dim cmd As New SqlCommand()
cmd.CommandText = "INSERT INTO Users (Username, Password, Email, PasswordQuestion, PasswordAnswer) VALUES(@Username,@Password,@Email,@PasswordQuestion,@PasswordAnswer)"
Dim param1 As New SqlParameter()
param1.ParameterName = "@Username"
param1.Value = txtUsername.Text.Trim()
cmd.Parameters.Add(param1)
Dim param2 As New SqlParameter()
param2.ParameterName = "@Password"
param2.Value = txtPassword.Text.Trim()
cmd.Parameters.Add(param2)
Dim param3 As New SqlParameter()
param3.ParameterName = "@Email"
param3.Value = txtEmail.Text.Trim()
cmd.Parameters.Add(param3)
Dim param4 As New SqlParameter()
param4.ParameterName = "@PasswordQuestion"
param4.Value = txtSecurityQuestion.Text.Trim()
cmd.Parameters.Add(param4)
Dim param5 As New SqlParameter()
param5.ParameterName = "@PasswordAnswer"
param5.Value = txtSecurityAnswer.Text.Trim()
cmd.Parameters.Add(param5)
cmd.Connection = cn
cmd.ExecuteNonQuery()
cn.Close()
End Using
Successlbl.show
Successlbl.show.Text = "Regisration Success."
Catch
Errolbl.Show()
Errolbl.Text = "Your account was not created.Please try again."
End Try
任何人都可以點我在哪裏,我會犯錯。
這是最終的結果,而進入到數據庫我得到:
更短,明確我需要輸入上面顯示用戶的詳細情況使用HDI會員我的數據庫供應商。
@ Downvoter,而不是把的 - 1你能否提供一些信息,以便我可以嘗試改進我的問題,以便更好地理解它。 – coder 2012-01-01 10:36:56
(沒有downvote)目前還不清楚你的實際問題是什麼。你需要從你的(winforms)應用程序中修改app.config,還是在構建或部署應用程序時修改? – Filburt 2012-01-01 10:42:20
當我將應用程序部署爲當我嘗試創建新用戶時,值不會輸入到我的數據庫中,因爲最近我在這裏提出了問題http://stackoverflow.com/questions/8692584/inserting-data-into-sqlserver-database-using -vb-net/8692611#8692611.So現在提到的應用程序路徑是根據我的HDI成員資格提供程序手動輸入的,所以我需要在app.config文件中提及我的應用程序名稱。 – coder 2012-01-01 10:44:46