自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

在Asp.net中利用MySQL數(shù)據(jù)庫進(jìn)行驗證

數(shù)據(jù)庫 MySQL
本文主要向大家講述的是在Asp.net中利用MySQL數(shù)據(jù)庫進(jìn)行驗證的實際操作步驟,以下就是文章的主要內(nèi)容描述,望你會從中得到自己想要的東西。

以下的文章主要向大家描述的是在Asp.net中利用MySQL數(shù)據(jù)庫進(jìn)行驗證 ,一直想把Asp.net與MySQL數(shù)據(jù)庫結(jié)合起來,包括使用.net自帶的 providers、membership、roles等登錄驗證,因為MsSql太大了,個人使用沒有必要。

在網(wǎng)上Google了半天,沒有發(fā)現(xiàn)有價值的東西,大都是些如果讀取、寫入MySQL數(shù)據(jù)等,而且網(wǎng)上還有很多誤導(dǎo)信息,要通過一些開源的插件(類)來實現(xiàn)。其實,MySQL數(shù)據(jù)庫官方的 MySQL-connector-net 早在5.1版本就支持asp.net authorization 了,可以在官方網(wǎng)站和google卻很少有配置教程,最終我在一土耳其網(wǎng)站上找到了詳細(xì)的配置說明,現(xiàn)整理如下:

1、下載 MySQL Connector,我下載的是5.2.5,地址:http://dev.MySQL.com/downloads/connector/net/5.2.html,要用安裝版本,這樣在安裝過程中會對machine.config 、vs2008 等進(jìn)行一些默認(rèn)配置,省去了手動配置的麻煩。

2、在網(wǎng)站web.config文件上添加ConnectionString

 

  1. <connectionStrings>   
  2. <remove name="LocalMySQLServer"/>   
  3. <add name="LocalMySQLServer" connectionString="server=localhost; 
    user id=root; password=toor; persist security info=true; database=dorknozzle;
    "
     providerName="MySQL.Data.MySQLClient"/>   
  4. </ connectionStrings> 

3、把MySQL.Data.dll文件復(fù)制到網(wǎng)站bin文件夾并添加引用

4、在machine.config (c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config)中添加 autogenerateschema="true" ,自動生產(chǎn)相關(guān)表格結(jié)構(gòu),如下:

 

  1. <membership>   
  2. <providers>   
  3. <add name="MySQLMembershipProvider" autogenerateschema="true" type="MySQL.
    Web.Security.
    MySQLMembershipProvider, MySQL.Web, Version=5.2.2.0, ... />   
  4. </providers>   
  5. </membership> 

5、在Vistual stuido 2008中打開Asp.net 網(wǎng)站管理工具(項目 > ASP.NET 配置),在“提供程序”頁面選擇“為每項功能選擇不同的提供程序(高級)”,接下來在“成員資格提供程序”中選擇MySQLMembershipProvider ,在“角色提供程序”中選擇MySQLRoleProvider 。

6、接下來就是享受Asp.net 和 MySQL數(shù)據(jù)庫 帶來的樂趣吧!

測試過程中出現(xiàn)的以下錯誤再也不見了(英文版出錯信息,中文版出錯信息沒有保存):

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to initialize provider. Missing or incorrect schema.(c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 145)

 

 

以上的相關(guān)內(nèi)容就是對在Asp.net中利用MySQL數(shù)據(jù)庫進(jìn)行驗證的介紹,望你能有所收獲。

【編輯推薦】

  1. MySQL 常用語句的基本用法的介紹
  2. 解決MySQL遠(yuǎn)程訪問不允許得個好用方案
  3. 解決MySQL無法遠(yuǎn)程訪問的3方案
  4. PHP和MySQL存儲過程的實例演示
  5. MySQL編碼機(jī)制與亂碼
責(zé)任編輯:佚名 來源: cnblogs
相關(guān)推薦

2010-05-25 08:49:33

連接MySQL

2010-06-07 14:34:49

連接MySQL 數(shù)據(jù)庫

2009-07-20 17:03:55

批量插入數(shù)據(jù)ASP.NET

2009-08-04 15:02:18

ASP.NET數(shù)據(jù)驗證

2009-07-28 14:16:31

ASP.NET與MyS

2009-04-17 09:36:25

ASP.NETOracleWinform

2009-02-23 15:20:03

SQL Server數(shù)據(jù)庫ASP.NET

2009-07-31 09:57:47

ASP.NET數(shù)據(jù)庫緩

2009-07-28 17:36:21

ASP.NET數(shù)據(jù)庫連

2009-07-29 09:59:10

ASP.NET For

2009-07-29 09:12:31

ASP.NET數(shù)據(jù)庫連

2009-08-11 12:52:05

ASP.NET數(shù)據(jù)庫程

2009-08-05 15:40:49

ASP.NET連接數(shù)據(jù)

2009-08-04 14:52:33

Visual Web ASP.NET

2009-09-18 10:20:26

PRG數(shù)據(jù)驗證

2009-08-04 15:20:59

ASP.NET數(shù)據(jù)驗證數(shù)據(jù)驗證控件

2009-08-05 09:38:28

SQL Server數(shù)

2009-08-05 15:29:33

ASP.NET For

2009-08-05 13:09:17

ASP.NET應(yīng)用執(zhí)行

2009-08-05 16:50:09

ASP.NET For
點贊
收藏

51CTO技術(shù)棧公眾號