1:
打包生成脚本文件createDB.sql
2:
定义以下过程
Private Sub CreateDataBase(cnDataBase as connect,sqlFile As String)
Dim strSql As String, strTmp As String
Open sqlFile For Input As #1
strSql = ""
Do While Not EOF(1)
Line Input #1, strTmp
If UCase(strTmp) = "GO" Then
cn.Execute strSql
strSql = ""
Else
strSql = strSql & strTmp & vbCrLf
End If
Loop
If strSql <> "" Then cnDataBase.Execute strSql
Close #1
End Sub
注:cnDatabase 为你到服务器的连接
sqlFile 为你的脚本文件(带路径)
3:
在你的程序开始时期运行以上过程
call createdatabase(cn,app.path+"\createDB.sql")