Dim CNN As New ADODB. Connection
CNN. The ConnectionString="Provider=SQLOLEDB. 1; Password=111; Persist Security Info=True; User ID=sh; Initial Catalog=SHKS; Data Source=LENOVO - PC \ SQLEXPRESS;"
CNN. Open
Dim CMD As New ADODB.Com mand
If CNN. State=adStateOpen Then
The Set CMD. The ActiveConnection=CNN
Cmd.Com mandText="update table set sales time='" & amp; Trim (Text3. Text) & amp; "', sales amount=" & amp; Trim (Text4. Text) & amp; "', the sales amount=" & amp; Trim (Text5. Text) & amp; "' where product number=" & amp; Trim (Text1. Text) & amp; "' and vendor number=" & amp; Trim (Text2. Text) & amp; "'
"CMD. The Execute
MsgBox "success!"
End the If
End Sub
My code is like this but whether or not the database is the product number and vendor number will show success
How can I think the first to determine whether the database is corresponding to the product number and vendor number again modified
Just on the university students to do course design is still a small white and sql2008 great god help using vb6.0 by use
CodePudding user response:
CMD. Execute the execution of the outcome, you don't judge!You such code, as long as the CNN. Open implementation success,
Regardless of CMD. Execute the implementation of how, have to be performed: MsgBox "modify success!"
CodePudding user response:
For the press line to return to the Command:Command. The Execute RecordsAffected, the Parameters, the Options
The return value
Return you object references,
Parameter
RecordsAffected optional, long integer variables, that is affected by the provider to its return operation record number, RecordsAffected parameter applies only to query or stored procedure operation, RecordsAffected don't return by return the result of a query or stored procedure returns the number of records,
You can try to add this parameter
Dim r1 as long
CMD. The Execute r1
If r1=0 then msgbox "failure"
CodePudding user response:
VB to help with a few lines ofThe Execute method (ADO Command)
Perform the specified query in the CommandText property ACTS, SQL statements or stored procedures,
Syntax
For the line to return to the Command:
The Set you=command. The Execute (RecordsAffected, the Parameters, the Options)