Option Explicit Public mCnnString As String '工程->引用->Microsoft ActiveX Data Objects 2.X Library '窗体上放DTPicker1、Command1、Command2、Command3、Text1、Text2 '数据库Test中有一个学生表,其中有学生(nvarchar),入学总分(int),入学时间(datetime)三个字段 Private Sub Command1_Click() Dim mRst As New ADODB.Recordset mRst.CursorLocation = adUseClient mRst.Open "Select * From 学生表 Where 1 = 0", mCnnString, adOpenStatic, adLockOptimistic, adCmdText mRst.AddNew mRst("学生姓名") = Text1.Text mRst("入学总分") = Text2.Text mRst("入学时间") = Format((DTPicker1.Value), "yyyy-mm-dd") mRst.Update mRst.Close Set mRst = Nothing End SubPrivate Sub Command2_Click() Dim mCnn As New ADODB.Connection mCnn.ConnectionString = mCnnString mCnn.Open mCnn.Execute ("Delete From 学生表 Where 入学时间 = '" & "2004-05-13'") mCnn.Close Set mCnn = Nothing End SubPrivate Sub Command3_Click() Dim mCnn As New ADODB.Connection mCnn.ConnectionString = mCnnString mCnn.Open mCnn.Execute ("Insert Into 学生表(学生姓名,入学总分,入学时间) Values('" & "也金'," & "897,'" & "2004-05-13')") mCnn.Close Set mCnn = Nothing End SubPrivate Sub Form_Load() mCnnString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Test;Data Source=Server" End Sub
Dim wre As New adodb.Recordset Dim wcn As New adodb.Connection Dim wstr As String Dim wsq, wwh As String wwh = "" wsq = "delete * from 年度工资表 where 年份='" & Text4.Text & "'" wstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\职工工资调试\wage.mdf;Persist Security Info=False" wcn.Open wstr msg = MsgBox("你确定要删除'" & Text4.Text & "'的年度的工资表吗?删除以后不可恢复!请慎重", 4 + 32 + 0, "删除提示") If msg = vbYes Then wre.Open Trim$(wsq), wcn, adOpenKeyset, adLockOptimistic Else Call Form6.deleyear End If 'wre.Update 'wre.Close wcn.Close 'Set wre = Nothing Set wcn = Nothing
Public mCnnString As String
'工程->引用->Microsoft ActiveX Data Objects 2.X Library
'窗体上放DTPicker1、Command1、Command2、Command3、Text1、Text2
'数据库Test中有一个学生表,其中有学生(nvarchar),入学总分(int),入学时间(datetime)三个字段
Private Sub Command1_Click()
Dim mRst As New ADODB.Recordset
mRst.CursorLocation = adUseClient
mRst.Open "Select * From 学生表 Where 1 = 0", mCnnString, adOpenStatic, adLockOptimistic, adCmdText
mRst.AddNew
mRst("学生姓名") = Text1.Text
mRst("入学总分") = Text2.Text
mRst("入学时间") = Format((DTPicker1.Value), "yyyy-mm-dd")
mRst.Update
mRst.Close
Set mRst = Nothing
End SubPrivate Sub Command2_Click()
Dim mCnn As New ADODB.Connection
mCnn.ConnectionString = mCnnString
mCnn.Open
mCnn.Execute ("Delete From 学生表 Where 入学时间 = '" & "2004-05-13'")
mCnn.Close
Set mCnn = Nothing
End SubPrivate Sub Command3_Click()
Dim mCnn As New ADODB.Connection
mCnn.ConnectionString = mCnnString
mCnn.Open
mCnn.Execute ("Insert Into 学生表(学生姓名,入学总分,入学时间) Values('" & "也金'," & "897,'" & "2004-05-13')")
mCnn.Close
Set mCnn = Nothing
End SubPrivate Sub Form_Load()
mCnnString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Test;Data Source=Server"
End Sub
Dim wcn As New adodb.Connection
Dim wstr As String
Dim wsq, wwh As String
wwh = ""
wsq = "delete * from 年度工资表 where 年份='" & Text4.Text & "'"
wstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\职工工资调试\wage.mdf;Persist Security Info=False"
wcn.Open wstr
msg = MsgBox("你确定要删除'" & Text4.Text & "'的年度的工资表吗?删除以后不可恢复!请慎重", 4 + 32 + 0, "删除提示")
If msg = vbYes Then
wre.Open Trim$(wsq), wcn, adOpenKeyset, adLockOptimistic
Else
Call Form6.deleyear
End If
'wre.Update
'wre.Close
wcn.Close
'Set wre = Nothing
Set wcn = Nothing
sConnect = "provider=msdasql.1;dsn=aa;uid=" & gbC3user & ";pwd=" &
Set dfwConn = New ADODB.Connection
dfwConn.Open sConnect