如果出现了不认识的非法字符,多半是转脚本的时候每行开始的"if"转成了"f",(好像是个bug??)
对其进行另外的处理就可以了:
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 Left(strTmp, 3) = "f" Then strTmp = "if" & Right(strTmp, Len(strTmp) - 3)
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
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
其他的你可以定义一个到服务器的ado连接
然后可以这样:
比如:vb中
dim cn as New ADODB.Connection
dim sql as string