发表于:2005-01-13 16:30:00
2楼
和读写access一样!
Public Function SaveDataToParaDb(Noo, No1, No2, No3, No4, No5, No6, No7, No8, No9)
Dim SqlStr
Dim NowDate
Dim FileName
FileName="ParaDb"
Set FsoObj=CreateObject("Scripting.FileSystemObject")
FileName=FileDir & "\" & FileName & ".mdb"
If FsoObj.FileExists(FileName)=False Then
MakeParaDb FileDir,FileName
End If
FileName ="ParaDb"
NowDate = Mid(Now,1,10)
FileName = FileDir & "\" & FileName & ".mdb"
'MySqlStr ="Insert into ParaTab(Type,UpSpeed,MidSpeed,DownSpeed,MachineSpeed,SportSpeed,Length,Weigth," & _
' "UpTolerance,DownTolerance,ThenDate) VALUES('"+Trim(Noo)+"','"+Trim(No1)+"','"+Trim(No2)+"'," & _
' "'"+Trim(No3)+"','"+Trim(No4)+"','"+Trim(No5)+"','"+Trim(No6)+"','"+Trim(No7)+"','"+Trim(No8)+"'," & _
' "'"+Trim(No9)+"','"+NowDate+"')"
ConStr =DbDriver + "Data Source=" + FileName + ";" & "Persist Security Info=True;"
MsgBox("Mtype=:" & Mtype)
SqlStr ="Insert into ParaTab(Type,UpSpeed,MidSpeed,DownSpeed,MachineSpeed,SportSpeed,Length,Weigth,UpTolerance,DownTolerance,NowDate) VALUES (" & Noo & "," & Trim(No1) & "," & Trim(No2) & "," & Trim(No3) & "," & Trim(No4) & "," & Trim(No5) & "," & Trim(No6) & "," & Trim(No7) & "," & Trim(No8) & "," & Trim(No9) & "," & NowDate & ")"
'SqlStr="Insert into ParaTab(Type,UpSpeed,MidSpeed,ThenDate) VALUES ("" & Trim(Noo) & ""," & Trim(No1) & "," & Trim(No2) & "," & NowDate & ");"
Set ObjConnection = CreateObject("ADODB.Connection")
ObjConnection.ConnectionString = ConStr
ObjConnection.Open
Set ObjCommand=CreateObject("ADODB.Command")
With ObjCommand
.ActiveConnection = ObjConnection
.CommandText = SqlStr
End With
ObjCommand.Execute
MsgBox(ObjCommand.CommandText)
Set ObjCommand=Nothing
ObjConnection.Close
Set ObjConnection=Nothing
End Function