Home > Software engineering >  For help: using vb to SQL SERVER2000 table inserted into the database, how random insertion of a rec
For help: using vb to SQL SERVER2000 table inserted into the database, how random insertion of a rec

Time:10-04

The program code is as follows: Sub procedure3
Sub procedure3
Dim sPro
Dim sDsn
Dim sSer
Dim sCon
Dim sSql
Dim conn
Dim oRs
Dim oCom
Dim myMinute, mySecond

Dim TintData TfloatData, TboolData TstringData, Tdate, Ttime
TintData=https://bbs.csdn.net/topics/HMIRuntime.tags (" TintData "). The Read
TfloatData=https://bbs.csdn.net/topics/HMIRuntime.tags (" TfloatData "). The Read
TboolData=https://bbs.csdn.net/topics/HMIRuntime.tags (" TboolData "). The Read
TstringData=https://bbs.csdn.net/topics/HMIRuntime.tags (" TstringData "). The Read
Tdate=HMIRuntime. Tags (" Tdate "). The Read
Ttime=HMIRuntime. Tags (" Ttime "). The Read
MyMinute=HMIRuntime. Tags (" Tminute1 "). The Read
MySecond=HMIRuntime. Tags (" Tsecond1 "). The Read


If ((myMinute=0 And mySecond=0) Or (myMinute=10 And mySecond=0) Or (myMinute=20 And mySecond=0) Or (myMinute=30 And mySecond=0) Or (myMinute=40 And mySecond=0) Or (myMinute=50 And mySecond=0)) Then


SCon="Provider=SQLOLEDB. 1; Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=test; Data Source=GUANLV02 \ WINCC "

sSql="insert into Table6 (Tdate, Ttime, TintData TfloatData, TboolData, TstringData) values ('" & amp; Tdate & amp; "', '" & amp; Ttime & amp; "'," & amp; TintData & amp; ", "& amp; TfloatData & amp; ", "& amp; TboolData & amp; ", '" & amp; TstringData & amp; "')"

Set the conn=CreateObject (" adodb. Connection ")
Conn. The connectionstring=sCon
Conn. Open

The Set oRs=CreateObject (" adodb. You ")
Mand Set oCom=CreateObject (" adodb.com ")
OCom.com mandType=1
The Set oCom. ActiveConnection=conn
OCom.com mandText sSql=

The Set of oRs=oCom. Execute

The Set oCom=Nothing
Conn. Close
The Set of oRs=Nothing
Set the conn=Nothing
End the If
End Sub
Perform database after the results are as follows:
Consult:
Why is this? Is my SQL insert statement is not complete? Or what other reason?
My request is to insert time is according to the descending order, how to do?
Thank you for your attention!

CodePudding user response:

Insertion order is not important, what do you want to order, query time and the order by is ok,

CodePudding user response:

Select * from table name for the order by the field name desc
This query is displayed when descending order according to the specified field

CodePudding user response:

refer to the second floor Leftie response:
select * from table name for the order by the field name desc
This query is displayed when descending order in the specified field in the
+ 1

CodePudding user response:

Ttime of the definition of the field name is a string, select statement using order by statement is wrong, and what measures can be recorded by descending order?
If you don't change the type of database how to do?
If change the time type to datatime, how should do?
Which good do some?
Thank you

CodePudding user response:

refer to the second floor Leftie response:
select * from table name for the order by the field name desc
This query is displayed when descending order in the specified field in the


Can say in cantonese? . This I also troubling

CodePudding user response:

Random database insert position, because it is not important.
If you want to in a certain order, you just need to at the time of the query and sort
  • Related