首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

不支持关键字: “provider”。 哥哥姐姐 各位老师 救救小弟我吧 困扰小弟我几天了

2012-01-15 
不支持关键字: “provider”。 哥哥姐姐各位老师 救救我吧困扰我几天了谢谢各位帮忙看看啊谢谢谢谢谢谢谢~~~~

不支持关键字: “provider”。 哥哥姐姐 各位老师 救救我吧 困扰我几天了
谢谢各位帮忙看看啊 谢谢谢谢谢谢谢~~~~~~~~~~~~~~~~~~~~
在登陆页面里面 输入帐号密码登陆后就显示 不支持关键字: “provider”。 
支持关键字: “provider”。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.ArgumentException: 不支持关键字: “provider”。

源错误: 


行 17: ByVal username As String, _
行 18: ByVal password As String) As Boolean
行 19: Dim conn As SqlConnection = New SqlConnection(_connStr)
行 20: Try
行 21: conn.Open()
 


web.config文件源代码

VB.NET code
<?xml version="1.0"?><configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">    <appSettings/>  <connectionStrings>    <add name="MySqlConnection"     connectionString="Provider=System.Data.SqlClient;     Data Source=.\SQLEXPRESS;     AttachDbFilename='|DataDirectory|\Database.mdf;     Integrated=' Security=True;        User Instance=True"/>  </connectionStrings>    <system.web>    <authentication mode="Forms">      <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH">      </forms>    </authentication>    <authorization>      <deny users="?"/>    </authorization>    <membership      defaultProvider="myoamembershipprovider">      <providers>        <add name="myoamembershipprovider"             connectionStringName="MySqlConnection"           type="myoamembershipprovider"            requiresQuestionAndAnswer="true"      />      </providers>    </membership>          <compilation debug="true" strict="false" explicit="true"/>      <pages>        <namespaces>          <clear/>          <add namespace="System"/>          <add namespace="System.Collections"/>          <add namespace="System.Collections.Specialized"/>          <add namespace="System.Configuration"/>          <add namespace="System.Text"/>          <add namespace="System.Text.RegularExpressions"/>          <add namespace="System.Web"/>          <add namespace="System.Web.Caching"/>          <add namespace="System.Web.SessionState"/>          <add namespace="System.Web.Security"/>          <add namespace="System.Web.Profile"/>          <add namespace="System.Web.UI"/>          <add namespace="System.Web.UI.WebControls"/>          <add namespace="System.Web.UI.WebControls.WebParts"/>          <add namespace="System.Web.UI.HtmlControls"/>        </namespaces>      </pages> </system.web></configuration>


myoamembershipprovider.vb 的代码
VB.NET code
Imports Microsoft.VisualBasicImports System.Data.SqlClientPublic Class myoamembershipprovider    Inherits SqlMembershipProvider    Private _connStr As String = " "    Public Overrides Sub Initialize( _    ByVal name As String, _    ByVal config As System.Collections.Specialized.NameValueCollection)        _connStr = ConfigurationManager.ConnectionStrings("MySqlConnection").ConnectionString        MyBase.Initialize(name, config)    End Sub    Public Overrides Function ValidateUser( _    ByVal username As String, _    ByVal password As String) As Boolean        Dim conn As SqlConnection = New SqlConnection(_connStr)        Try            conn.Open()            Dim sql As String = "select * from T_users where loginname=@username AND password =@password"            Dim comm As New SqlCommand(sql, conn)            comm.Parameters.AddWithValue("@username", username)            comm.Parameters.AddWithValue("@password", password)            Dim reader As SqlDataReader = comm.ExecuteReader            If reader.HasRows Then                reader.Read()                If (password.Equals(reader.Item("password").ToString())) Then                    Return True                Else                    Return False                End If            Else                Return False            End If            conn.Close()        Catch ex As Exception            Return False        End Try        Return MyBase.ValidateUser(username, password)    End FunctionEnd Class 



[解决办法]
web.config中修改连接字符串如下

XML code
<connectionStrings>  <add name="MySqlConnection"   connectionString="Data Source=.\SQLEXPRESS;   AttachDbFilename='|DataDirectory|\Database.mdf;   Integrated=' Security=True;      User Instance=True"   Provider="System.Data.SqlClient"  /></connectionStrings>
[解决办法]
Provider="System.Data.SqlClient" 去去掉么好了

热点排行