我现在有一个存储过程,它的参数是开始时间和结束时间。执行这个存储过程可以将数据存入到User表中,
现在我想做一个VB小程序里面包括两个DTPicker和一CommandButton,
选择好DTPicker的值,然后单机CommandButton,就可以将数据存入到User表中。
我想知道在
Private Sub CommandButton_Click()
End Sub
里面我要怎样写啊?没有做过,求教!!
谢谢!!
现在我想做一个VB小程序里面包括两个DTPicker和一CommandButton,
选择好DTPicker的值,然后单机CommandButton,就可以将数据存入到User表中。
我想知道在
Private Sub CommandButton_Click()
End Sub
里面我要怎样写啊?没有做过,求教!!
谢谢!!
Dim dt2 as String
dt1=Format(Now-20#/3600#/24#, "YYYY-MM-DD hh:mm:ss")
dt2=Format(Now, "YYYY-MM-DD hh:mm:ss")
conn.Exec “insert into tablename (dt1,dt2) values ('"+dt1+"','"+dt2+"')"
conn.Exec “insert into tablename (dt1,dt2) values ('"+dt1+"','"+dt2+"')"
这里是要往表里面插入数据,我的这个表里面有很多的字段,而且时间字段就有一个,如果要像你这样做的话,
那我这个表里面可就有好多字段都是Null值了
conn.Exec “sp_my_store_procedure '"+dt1+"','"+dt2+"'"
这是我做的一个简单的页面。Private Sub cmdStatistics_Click()
strSQL = "exec ProcSateUserCash @BDate='" + StdValue(dtpSTime.Value, stDateTime) + "',@EDate='" + StdValue(dtpETime.Value, stDateTime) + "' "End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Form_Load()
dtpSTime.Value = "2014-02-01"
dtpETime.Value = Now
End Sub这是我写的后台代码,但是不对,我执行了之后,查看数据库,没有生成数据。
我现在还行往里面加入点东西,
因为数据量比较大所以,我想当统计的时候有提示“正在统计现金说数据”
当统计结束的时候提示“现金数据统计成功”。麻烦你帮忙看看要怎样改!谢谢
Private Sub cmdStatConsume_Click()Dim strSQL As String
Dim aFields() As String
Dim sTime As String
Dim eTime As String
Dim deptIDs As String
Dim adoComm As Object
Set adoComm = CreateObject("ADODB.Command")sTime = StdValue(dtpSTime.Value, stDate)
eTime = StdValue(dtpETime.Value, stDate)mvarLastError = ""On Error GoTo errFlag
If conn.State <> 1 Then conn.Open
'// 设置连接
Me.MousePointer = ccHourglass
adoComm.ActiveConnection = conn
adoComm.CommandType = adCmdStoredProc
adoComm.CommandText = "ProcUserCash"
adoComm.Parameters("@BTime") = sTime
adoComm.Parameters("@ETime") = eTime '// 执行存储过程
Set rsConsumeInfo = adoComm.Execute
If Not rsConsumeInfo.EOF Then Application.DisplayStatusBar = True
Application.StatusBar = "正在运行中。,请稍候..."
Set rsConsumeInfo = Nothing
Else
mvarLastError = "未查询到任何结果"
MsgBox mvarLastError, vbInformation, "提示"
End If
'// 释放对象
Set adoComm = Nothing
If rsConsumeInfo.State <> 0 Then rsConsumeInfo.Close
Set rsConsumeInfo = Nothing
Me.MousePointer = ccDefault
On Error GoTo 0
Exit Sub
errFlag:
Me.MousePointer = ccDefault
Set adoComm = Nothing
If rsConsumeInfo.State <> 0 Then rsConsumeInfo.Close
Set rsConsumeInfo = Nothing
mvarLastError = "发生错误,程序无法正常运行"
MsgBox mvarLastError, vbInformation, "提示"
End Sub
这样执行的时候发生了错误,错误提示为“发生错误,程序无法正常运行”
这样要怎样修改啊?