国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

快速搭建ERP的數(shù)據(jù)庫框架

2024-07-21 02:12:37
字體:
供稿:網(wǎng)友
菜鳥學(xué)堂:
(本文以sql server為數(shù)據(jù)庫服務(wù)器,t-sql是標準sql語言的擴充。)在erp的軟件中,數(shù)據(jù)庫是它的靈魂。每一個erp軟件都有自己的數(shù)據(jù)庫,而這些數(shù)據(jù)庫中最關(guān)鍵的是數(shù)據(jù)庫框架。那么什么是數(shù)據(jù)庫框架?他的

作用是什么?為什么要在安裝時搭建數(shù)據(jù)庫框架?本文就來解答這些問題。

  在編寫erp,mis,s/b等數(shù)據(jù)庫的應(yīng)用程序時,首先要做的一件事就是建立數(shù)據(jù)庫框架,它至少包括:數(shù)據(jù)庫和數(shù)據(jù)庫中的表,當(dāng)然還有視圖、存儲過程等,這就是數(shù)據(jù)庫框架(不含具體的數(shù)據(jù))。然后是使用vb,vc,vfp,pb等編程語言開發(fā)用戶界面,接受用戶對數(shù)據(jù)庫的操作。當(dāng)你成功的開發(fā)了一個erp軟件后,你需要將它打包,最后交給客戶安裝并使用。這時就有一個問題,當(dāng)你打包的時候,不可以將sql server打包到安裝程序中,所以用戶在使用時就必須先建立數(shù)據(jù)庫框架,而用戶并不知道數(shù)據(jù)庫的框架結(jié)構(gòu),erp軟件又必須訪問特定的數(shù)據(jù)庫框架才可以成功運行,這時我們就需要有一個可以自動生成數(shù)據(jù)庫框架的程序。舉個例:當(dāng)開發(fā)一個人力資源管理系統(tǒng)時,需要一個數(shù)據(jù)庫框架,這最起碼在數(shù)據(jù)庫包含一個表,表中包含姓名,年齡,工資等信息,然后通過客戶端來訪問這個表。如果沒有這個表,程序就不可能成功的運行。現(xiàn)在大家清楚了什么是數(shù)據(jù)庫框架和他的作用了吧!

  現(xiàn)在的erp軟件中都帶有自動生成數(shù)據(jù)庫框架的功能,不同軟件的實現(xiàn)方法不同,總結(jié)一下,大約有3種:

  1.以向?qū)У男问匠霈F(xiàn);

  2.在安裝時以配置系統(tǒng)的形式出現(xiàn);

  3.集成在主程序中,當(dāng)主程序第一次運行的時候自動生成數(shù)據(jù)庫框架。

  不論是那種方式,他們的用途都是一樣。    

    如果大家有《管家婆》的erp,可以安裝來看看。它要求先安裝sql server ,安裝完后打開sql server你會發(fā)現(xiàn)sql server數(shù)據(jù)庫中只有它默認的幾個數(shù)據(jù)庫,并沒什么不同。接著開始安裝《管家婆》,安裝完后隨便用一下他的功能,再大開sql server你會發(fā)現(xiàn),數(shù)據(jù)庫已不同了,增加了一些數(shù)據(jù)庫(增加的數(shù)據(jù)庫因使用的功能和《管家婆》的版本不同而不同)。這些增加的數(shù)據(jù)庫就是為了使用數(shù)據(jù)庫框架自動生成。

  那么,如何用程序?qū)崿F(xiàn)自動生成數(shù)據(jù)庫框架?現(xiàn)在,我們就來創(chuàng)建一個這樣的程序。在本程序中共建立5個按鈕分別是:建立數(shù)據(jù)庫,建立表,建立約束,建立存儲過程,顯示數(shù)據(jù)。實現(xiàn)的代碼如下:

  public class form1

  inherits system.windows.forms.form

  private sub button1_click(byval sender as system.object, byval e as system.eventargs)

  handles button1.click

  dim con as new oledb.oledbconnection("provider=sqloledb.1;integrated

  security=sspi;persist security info=false;initial catalog=northwind;data

  source=.;use procedure for prepare=1;auto translate=true;packet

  size=4096;workstation id=j;use encryption for data=false;tag with column collation

  when possible=false")

  con.open()

  dim cmd as new oledb.oledbcommand("create database jk", con)

  cmd.executenonquery()

  con.close()

  '建立數(shù)據(jù)庫

  end sub

  private sub button2_click(byval sender as system.object, byval e as

  system.eventargs) handles button2.click

  dim con2 as new oledb.oledbconnection("provider=sqloledb.1;integrated

  security=sspi;persist security info=false;initial catalog=jk;data source=.;use

  procedure for prepare=1;auto translate=true;packet size=4096;workstation id=j;use

  encryption for data=false;tag with column collation when possible=false")

  con2.open()

  dim cmd as new oledb.oledbcommand("create table kk(id int identity(1,1) not

  null constraint id primary key,name char(4) not null)", con2)

  cmd.executenonquery()

  dim cmd2 as new oledb.oledbcommand("create table pp(id int not null,ads

  char(20) null)", con2)

  cmd2.executenonquery()

  con2.close()


 '建立2個表

  end sub

  private sub button3_click(byval sender as system.object, byval e as

  system.eventargs) handles button3.click

  dim con2 as new oledb.oledbconnection("provider=sqloledb.1;integrated

  security=sspi;persist security info=false;initial catalog=jk;data source=.;use

  procedure for prepare=1;auto translate=true;packet size=4096;workstation id=j;use

  encryption for data=false;tag with column collation when possible=false")

  con2.open()

  dim com as new oledb.oledbcommand("alter table pp add primary key (id)",

  con2)

  com.executenonquery()

  con2.close()

  '建立約束

  end sub

  private sub button4_click(byval sender as system.object, byval e as

  system.eventargs) handles button4.click

  dim con2 as new oledb.oledbconnection("provider=sqloledb.1;integrated

  security=sspi;persist security info=false;initial catalog=jk;data source=.;use

  procedure for prepare=1;auto translate=true;packet size=4096;workstation id=j;use

  encryption for data=false;tag with column collation when possible=false")

  con2.open()  

  dim com as new oledb.oledbcommand("create proc procname as select * from

  kk", con2)

  com.executenonquery()

  con2.close()

  '建立存儲過程

  end sub

  private sub button5_click(byval sender as system.object, byval e as

  system.eventargs) handles button5.click

   dim con2 as new oledb.oledbconnection("provider=sqloledb.1;integrated

  security=sspi;persist security info=false;initial catalog=jk;data source=.;use

  procedure for prepare=1;auto translate=true;packet size=4096;workstation id=j;use

  encryption for data=false;tag with column collation when possible=false")

  dim com as new oledb.oledbcommand("procname", con2)

  dim da as new oledb.oledbdataadapter()

  da.selectcommand = com

  dim ds as new dataset()

  da.fill(ds)

  datagrid1.datasource = ds

  '顯示數(shù)據(jù)

  end sub

  end class

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 万山特区| 临海市| 玉林市| 松潘县| 赣榆县| 柳州市| 新晃| 新密市| 开鲁县| 且末县| 镇平县| 昌吉市| 朝阳区| 义乌市| 泸定县| 乌鲁木齐县| 泸定县| 墨竹工卡县| 武鸣县| 定结县| 香港| 察雅县| 大姚县| 玉树县| 上林县| 蓬莱市| 铜陵市| 鸡泽县| 株洲市| 沅江市| 朝阳县| 宾阳县| 河南省| 广汉市| 张家川| 永靖县| 松江区| 烟台市| 甘谷县| 东乌珠穆沁旗| 凯里市|