Home > Software engineering >  How to use a small program to invoke the VB with two time parameters of the stored procedure???????
How to use a small program to invoke the VB with two time parameters of the stored procedure???????

Time:10-08

I now have a stored procedure, and its parameters is the start time and end time, execute the stored procedure in the table data can be stored in to the User,
Now I want to do a small VB program includes two DTPicker and a CommandButton,
Choose good DTPicker value, and then single CommandButton, data can be stored in the User table,
I want to know the
Private Sub CommandButton_Click ()


End Sub
How do I write inside? Didn't do it, ask!!!!!
Thank you very much!!

CodePudding user response:

 Dim dt1 as String 
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 +") "

CodePudding user response:

But I want to enforce a stored procedure,
Conn. Exec "insert into tablename (dt1 dt2) values ('" + dt1 + "', '" + dt2 +") "
Here is to want to insert the data table, this table I have a lot of fields, and one time field, if you like you do so, the
I'll have this table can be a lot of fields are Null values

CodePudding user response:

Assume that your stored procedure sp_my_store_procedure need two datetime types of parameters:
 conn. Exec sp_my_store_procedure "'" + dt1 + "', '" + dt2 +"' "

CodePudding user response:


This is I do a simple page,

Private Sub cmdStatistics_Click ()
StrSQL="exec ProcSateUserCash @ BDate='" + StdValue (dtpSTime. Value, stDateTime) +"', @ EDate='" + StdValue (dtpETime. Value, stDateTime) + "' "

End Sub

Private Sub Command2_Click ()
Unload Me
End Sub

Private Sub Form_Load ()
DtpSTime. Value="https://bbs.csdn.net/topics/2014-02-01"
DtpETime. Value=https://bbs.csdn.net/topics/Now
End Sub

This is I write code, but no, I performed to check the database, not generate data,
I am ok to add something,
Because data volume is so big, I think there is prompt when statistics "are cash said data"
When statistical tip at the end of the "cash statistics success",

Trouble you help see how to change! thank you

CodePudding user response:

I have modified the statistics button
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
Mand Set adoComm=CreateObject (" ADODB.Com ")

STime=StdValue (dtpSTime. Value, stDate)
ETime=StdValue (dtpETime. Value, stDate)

MvarLastError=""

On Error GoTo errFlag
If conn. State & lt;> 1 Then conn. Open
'//set the connection
Me. MousePointer=ccHourglass
AdoComm. ActiveConnection=conn
AdoComm.Com mandType=adCmdStoredProc
AdoComm.Com mandText="ProcUserCash"
AdoComm. The Parameters (" @ BTime ")=sTime
AdoComm. The Parameters (" @ ETime ")=ETime

'//execute the stored procedure
The Set rsConsumeInfo=adoComm. Execute

If Not rsConsumeInfo. EOF Then

Application. DisplayStatusBar=True
Application. The StatusBar="is running,,,,, please wait... "


The Set rsConsumeInfo=Nothing
The Else
MvarLastError="query to no results"
MsgBox mvarLastError vbInformation, "tip"
End the If

'
//release objectThe Set adoComm=Nothing
If rsConsumeInfo. State & lt;> 0 Then rsConsumeInfo. Close
The Set rsConsumeInfo=Nothing
Me. MousePointer=ccDefault
On Error GoTo 0
The Exit Sub
ErrFlag:
Me. MousePointer=ccDefault
The Set adoComm=Nothing
If rsConsumeInfo. State & lt;> 0 Then rsConsumeInfo. Close
The Set rsConsumeInfo=Nothing
MvarLastError="error occurs, the normal operation of the program"
MsgBox mvarLastError vbInformation, "tip"
End Sub
Such execution when an error occurred, error message for "error occurs, the normal operation of the program"
So how to change?
  • Related