This is my app.config file looks like:
I have figured out the problem Myself after a lot of hair pulling and found the solution that I have changed my code in this way:
cmd.CommandText = "INSERT INTO Users ( Username,ApplicationName,Password,
Email, PasswordQuestion, PasswordAnswer) VALUES(@Username,@ApplicationName,@Password,
@Email,@PasswordQuestion,@PasswordAnswer)"
And add another Param this way:
Dim param6 As New SqlParameter()
param6.ParameterName = "@ApplicationName"
param6.Value = txtApplicationName.Text.Trim()
cmd.Parameters.Add(param6)
I know this not the best way If anyone found any other best solution let me know.
Add a AppSettings section to your web.config
<appSettings>
<add key="ApplicationName" value="/website1" />
</appSettings>
There is a better way by using the following steps:
1) Add a reference to System.Configuration
to your application.
2) Add the following block to your app.config file, within the configuration
section:
<appSettings>
<add key="ApplicationName" value="/MyApplication" />
</appSettings>
3) Retrieve the value and use it where needed with the following code (example from your answer shown):
param6.Value = System.Configuration.ConfigurationManager.AppSettings("ApplicationName")