Dim DatabaseName As String
Dim sConnect As String
DatabaseName = App.Path & "\Anamnesis.mdb"
If Dir(DatabaseName) = "" Then
Dim dbDatabase As DAO.Database
Set dbDatabase = CreateDatabase(DatabaseName, dbLangGeneral, dbEncrypt)
dbDatabase.Close
Set dbDatabase = Nothing
sConnect = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & DatabaseName & ";Mode=Share Deny None;Extended Properties=';COUNTRY=0;CP=1252;LANGID=0x0409';Locale Identifier=1033;Jet OLEDB:System database='';Jet OLEDB:Registry Path='';Jet OLEDB:Global Partial Bulk Ops=2"
Set ConDatabase = New ADODB.Connection
ConDatabase.Open sConnect
DoEvents
ConDatabase.Execute "CREATE TABLE [Anamnesis] (" & _
"[THE_AnamnesisType] text (4)," & _
"[THE_AnamnesisID] text (7)," & _
"[THE_PatientName] text (8)," & _
"[THE_IDcard] text (18)," & _
"[THE_Sexual] text (2)," & _
"[THE_Birth] datetime," & _
"[THE_NativePlace] text (80)," & _
"[THE_Address] text (80)," & _
"[THE_Firm] text (80)," & _
"[THE_Employment] text (20)," & _
"[THE_InSectionTime] datetime," & _
"[THE_LeaveSectionTime] datetime," & _
"[THE_Goto] text (4)," & _
"[THE_Result] text (4)," & _
"[THE_Measure] text (255)," & _
"[THE_Diagnose] text (255)," & _
"[THE_Medico] text (8)," & _
"[THE_DiagnoseDate] datetime," & _
"[THE_State] text(4)," & _
"[THE_BorrowName] text(8)" & _
")"
DoEvents
ConDatabase.Execute "CREATE TABLE [Borrow] (" & _
"[THE_AnamnesisType] text (4)," & _
"[THE_AnamnesisID] text (7)," & _
"[THE_PatientName] text (8)," & _
"[THE_IDcard] text (18)," & _
"[THE_BorrowName] text (8)," & _
"[THE_BorrowIDcard] text (18)," & _
"[THE_BorrowFirm] text (80)," & _
"[THE_Introduce] text (80)," & _
"[THE_Use] text (80)," & _
"[THE_BorrowTime] datetime," & _
"[THE_ReturnTime] datetime" & _
")"
Else
sConnect = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabaseName & ""
Set ConDatabase = New ADODB.Connection
ConDatabase.Open sConnect
End If
我想在程序运行的时候判断一下数据库文件是否存在,如果不存在建立数据库,可老是不能建立数据库,不知问题出在哪里
Dim sConnect As String
DatabaseName = App.Path & "\Anamnesis.mdb"
If Dir(DatabaseName) = "" Then
Dim dbDatabase As DAO.Database
Set dbDatabase = CreateDatabase(DatabaseName, dbLangGeneral, dbEncrypt)
dbDatabase.Close
Set dbDatabase = Nothing
sConnect = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & DatabaseName & ";Mode=Share Deny None;Extended Properties=';COUNTRY=0;CP=1252;LANGID=0x0409';Locale Identifier=1033;Jet OLEDB:System database='';Jet OLEDB:Registry Path='';Jet OLEDB:Global Partial Bulk Ops=2"
Set ConDatabase = New ADODB.Connection
ConDatabase.Open sConnect
DoEvents
ConDatabase.Execute "CREATE TABLE [Anamnesis] (" & _
"[THE_AnamnesisType] text (4)," & _
"[THE_AnamnesisID] text (7)," & _
"[THE_PatientName] text (8)," & _
"[THE_IDcard] text (18)," & _
"[THE_Sexual] text (2)," & _
"[THE_Birth] datetime," & _
"[THE_NativePlace] text (80)," & _
"[THE_Address] text (80)," & _
"[THE_Firm] text (80)," & _
"[THE_Employment] text (20)," & _
"[THE_InSectionTime] datetime," & _
"[THE_LeaveSectionTime] datetime," & _
"[THE_Goto] text (4)," & _
"[THE_Result] text (4)," & _
"[THE_Measure] text (255)," & _
"[THE_Diagnose] text (255)," & _
"[THE_Medico] text (8)," & _
"[THE_DiagnoseDate] datetime," & _
"[THE_State] text(4)," & _
"[THE_BorrowName] text(8)" & _
")"
DoEvents
ConDatabase.Execute "CREATE TABLE [Borrow] (" & _
"[THE_AnamnesisType] text (4)," & _
"[THE_AnamnesisID] text (7)," & _
"[THE_PatientName] text (8)," & _
"[THE_IDcard] text (18)," & _
"[THE_BorrowName] text (8)," & _
"[THE_BorrowIDcard] text (18)," & _
"[THE_BorrowFirm] text (80)," & _
"[THE_Introduce] text (80)," & _
"[THE_Use] text (80)," & _
"[THE_BorrowTime] datetime," & _
"[THE_ReturnTime] datetime" & _
")"
Else
sConnect = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabaseName & ""
Set ConDatabase = New ADODB.Connection
ConDatabase.Open sConnect
End If
我想在程序运行的时候判断一下数据库文件是否存在,如果不存在建立数据库,可老是不能建立数据库,不知问题出在哪里
解决方案 »
- vb保存excel文件格式问题
- VB6.0动态加载用户开发的OCX控件,当控件超过一定数量时就出现加载错误,是内存限制还是什么原因啊?
- 一个函数的问题 关于year 请高手指教~
- 我在一个form里面用了2个windows media player 控件,w1和w2,如何让w1在form_load的时候就静音或者音量最小?
- 一个计算机电子书狂多的站点!!!(免费)
- 高分寻进销存系统得需求分析!!!!救名
- 180分救命呀!怎么样能模拟按键和鼠标操作?
- 有关grid问题,请问为什么?
- 为什么用WINSOCK发送大量的数据时,收不到完整的数据?
- VB读取XML文件中的值,并修改指定值,并保存
- 用vb能作图片切割吗?!
- 百分相送,关于选择文件夹很急很急很急很急!!!!
sql ="if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[表]" & chr(13) & "GO" & chr13 &
"CREATE TABLE [ado].[Borrow] (" & _
"[THE_AnamnesisType] text (4)," & _
"[THE_AnamnesisID] text (7)," & _
"[THE_PatientName] text (8)," & _
"[THE_IDcard] text (18)," & _
"[THE_BorrowName] text (8)," & _
"[THE_BorrowIDcard] text (18)," & _
"[THE_BorrowFirm] text (80)," & _
"[THE_Introduce] text (80)," & _
"[THE_Use] text (80)," & _
"[THE_BorrowTime] datetime," & _
"[THE_ReturnTime] datetime" & _
")"
ConDatabase.Execute sql