I am having issues accessing my ConnectionString in the web config.
Here is my web config.
<configuration>
<appSettings/>
<connectionStrings>
<add name="UAFConnectionString" connectionString="Provider=SQLOLEDB;Data Source=INLISAP003;Password=5q1server2005;User ID=sa;Initial Catalog=UserAccessForm"
providerName="System.Data.OleDb" />
</connectionStrings>
Here is my code for the button click,
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Dim mySqlCon As SqlConnection
Dim strConnection As String
Sub OpenCon()
strConnection = ConfigurationManager.ConnectionStrings("UAFConnectionString").ConnectionString
mySqlCon = New SqlConnection(strConnection)
mySqlCon.Open()
End Sub
Sub CloseCon()
mySqlCon.Close()
mySqlCon.Dispose()
End Sub
OpenCon()
Dim SQL As String = "SELECT * FROM tbl_UserAccount WHERE StafID='" & txtUsername.Text & "' AND Password='" & txtPassword.Text & "' "
Dim DR As SqlDataReader
Dim CMD As New SqlCommand(SQL, mySqlCon)
DR = CMD.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
DR.Read()
If DR.HasRows = False Then
MsgBox("Invalid User name OR Password", MsgBoxStyle.Critical, "Login ERROR")
txtUsername.Focus()
Exit Sub
End If
Here is my error message.
System.ArgumentException: Keyword not supported: 'provider'. at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at _Default.OpenCon() in D:\WEB-SITES\PROJECT002\Default.aspx.vb:line 12 at _Default.btnLogin_Click(Object sender, EventArgs e) in D:\WEB-SITES\PROJECT002\Default.aspx.vb:line 35