使用ADO。
谢谢!
谢谢!
解决方案 »
- 高级QQ群8017281
- 各位大侠请帮小弟作道面试题,先谢了!
- 急!使用DAO的程序打包后,安装在win2000上sql语句运行出错,请问是什么原因?
- 如何编程,通过windows(API,内建控件)访问驱动程序
- 我有一款软件想找个代理商做市面上销售,哪里有这样的代理商?
- 这是什么错?谢谢,一定进来看看!我是个新手所以好多不会呀
- 怎么将textbox中的数据保存为数据表
- Microsoft Translation Server(MTS)是什么?做什么要用?!
- 请问:怎样清空DTPicker时间控件初始显示的时间,当点击控件时再选时间。
- 我想要一个ACTIVEX.DLL源码
- 怎样建立Insert触发器
- 恳请帮忙:怎样才能在"非零元素位置"框中显示非零元素?(见内容)
Public Function CreateDB() As Boolean
Dim rst As New Recordset
'无数据库连接
myCnn.ConnectToServer False
'建库
strSql = "select name from sysdatabases where name='deptlists'"
rst.Open strSql, myCnn.Cnn, 3, 3
If rst.RecordCount > 0 Then
strSql = "drop database deptlists"
myCnn.Cnn.Execute strSql
End If
rst.Close
strSql = "create database DeptLists on (name='deptlist_m',filename=" & _
"'e:\第二学期\deptlist.mdf',size=1) log on (name='deptlist_l'," _
& "filename='e:\第二学期\deptlist.ldf',size=1)"
myCnn.Cnn.Execute strSql
'有库连接
myCnn.ConnectToServer
'建表
strSql = "create table Deptl (lngDeptID int primary key," _
& "lngFatherID int,StrDeptName varchar(20))"
myCnn.Cnn.Execute strSql
'插入记录
strSql = "insert into deptl select 1,0,'北京部' union" & _
" select 2,0,'上海部' union select 3, 0,'广州部' union" & _
" select 4,1,'海淀分部' union select 5,1,'朝阳分部' union" & _
" select 6,1,'西城分部' union select 7,2,'静安分部' union" & _
" select 8,2,'黄埔分部' union select 9,4,'知青路分部' union" & _
" select 10,4,'北外门分部'"
myCnn.Cnn.Execute strSql
'建表2
strSql = "create table RandNumAver(Num numeric)"
myCnn.Cnn.Execute strSql
'建存储过程
strSql = "create proc getdeptid as declare @newid int" & vbCrLf & _
"select @newid=max(lngdeptid) from deptl" & vbCrLf & _
"set @newid=@newid+1" & vbCrLf & "return @newid"
myCnn.Cnn.Execute strSql
Set rst = Nothing
CreateDB = True
Exit Function
ErrCreateDB:
MsgBox "数据库初始化失败!!!" & vbCrLf & Err.Description, _
vbCritical, "错误信息"
End Function
Public DAOWorkspace As dao.Workspace
Public DAODataBase As dao.Database
Set DAOWorkspace = DBEngine.Workspaces(0)
Set DAODataBase = DAOWorkspace.CreateDatabase(创建数据库路径, dbLangGeneral)
记得引用DAO
----------------------
《CSDN论坛新助手 CSDN's forum Explorer》
1、更快速的浏览
2、更方便地保存
3、更快捷的收/发短信
下载地址:http://www.seeyou.com.cn/CoolSlob/CSDNExplorer.exe
更多说明:http://community.csdn.net/Expert/TopicView.asp?id=3255966
“找不到可用的ISAM”
http://p2p.wrox.com/topic.asp?TOPIC_ID=1017
Public Sub newfile()
CommonDialog1.DialogTitle = "Please enter the new database name"
CommonDialog1.Filter = "Access database file MDB|*.mdb"
CommonDialog1.FileName = ""
CommonDialog1.InitDir = App.Path
CommonDialog1.ShowSave
dataname = CommonDialog1.FileName
If dataname = "" Then
Exit Sub
Else
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataname
End If
End Sub使用ADO+datagrid.引用ADOX 2.6