SQL數(shù)據(jù)庫轉(zhuǎn)access數(shù)據(jù)庫步驟:
1. 建立access數(shù)據(jù)庫:在access中建立access數(shù)據(jù)庫和表,access字段類型與sql中字段類型的對應(yīng)關(guān)系。
2. 在Access中建表是應(yīng)注意它的保留關(guān)鍵字:比如Password 如果表中的某個字段使用了關(guān)鍵字,那么會導(dǎo)致一系列的語句錯誤。比如update T_Users [email protected],[email protected] where [email protected]"此時就會提示"System.Data.OleDb.OleDbException: UPDATE 語句的語法錯誤".更多保留關(guān)鍵字可以參照互聯(lián)網(wǎng)。
3. 從sql導(dǎo)入數(shù)據(jù)到access數(shù)據(jù)庫。
注意:sql2008只能導(dǎo)出到access2007一下的版本的數(shù)據(jù)庫。
Asp.net應(yīng)做的修改
1. 修改連接字符串:
將<add name="DBStr"connectionString="data source=.;Database=shelian;integratedsecurity=true"/>改為
<addname ="DBStr"connectionString ="Provider=Microsoft.Je
提示:其中"Jet.OLEDB.4.0"對應(yīng)的是access2003版本,"|DataDirectory|"表示數(shù)據(jù)庫在App_Date目錄下。
2. 導(dǎo)入 using System.Data.OleDb;命名空間。
將以Sql開頭的SqlConnection , SqlCommand , SqlParameter, SqlDataAdapter, SqlParameter, SqlDataReader,SqlType等改成OleDbConnection ,OleDbCommand , OleDbParameter,OleDbDataAdapter, OleDbParameter, OleDbDataReader, OleDbType.
3. 修改。net文件中要操作的表中字段類型的
new SqlParameter("@CategoryName",SqlDbType.NVarChar,100),
newSqlParameter("@ParentId",SqlDbType.NVarChar,50),
newSqlParameter("@Path",SqlDbType.NVarChar,200),
newSqlParameter("@Depth",SqlDbType.Int,4),
newSqlParameter("@ChildIds",SqlDbType.NVarChar,50),
newSqlParameter("@IsActive",SqlDbType.Bit,1),
newSqlParameter("@ArticleNum",SqlDbType.Int,4),
newSqlParameter("@Readme",SqlDbType.NVarChar,200),
newSqlParameter("@CategoryId",SqlDbType.Int,4)};
改成:
new OleDbParameter("@CategoryName", OleDbType.LongVarWChar,100),
new OleDbParameter("@ParentId", OleDbType.LongVarWChar,50),
new OleDbParameter("@Path", OleDbType.LongVarWChar,200),
新聞熱點
疑難解答
圖片精選