Execute the dbSilentCmdText in a "stand alone" mode and returns the total records affected in executing multiple SQLs (-1 = error).

Version: All

Namespace:  Tornado
Assembly:  Tornado (in Tornado.dll) Version: 12.6.0.9 (1.0.0.0)

Syntax

C#
public long ASPdbExecuteCmd()
Visual Basic (Declaration)
Public Function ASPdbExecuteCmd As Long

Return Value

int irec = Mydb.ASPdbExecuteCmd

Remarks

  • You can use the ASPdbExecuteCmd to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements. ASPdbExecuteCmd uses ExecuteNonQuery to execute the commands. Although the ASPdbExecuteCmd returns no rows, any output parameters or return values mapped to parameters are populated with data. For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
  • SilentCmd is on an 'as-is' basis. No translation/filter of any kind will be applied. If you are tring to Add/Update records, make sure the data format is appropriate.
  • if dbSilentCmdText is not specified then dbSQL will be used instead.

Examples

CopyVB.NET
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
  Dim Ename As String = "Hello"
  Dim Eemail As String = "World"
  Dim userdb As String = Server.MapPath("/MySite/Mydb.mdb") 
  Dim x As New Tornado.z
    x.dbQP = "u=1|Q=Eval|D=" & userdb
    Dim pur As String = CStr(Now())
    Dim maint As String = CStr(Now())
    Dim values As String = "('" & Ename & "'," & "'" & Eemail & "'," & "#" & pur & "#," & "#" & maint & "#)"
    x.dbSilentCmdText = "com=INSERT INTO Eval (Ename,Eemail,purchase,maint) VALUES " & values
    If x.ASPdbExecuteCmd() > 0 Then
        Response.Write("Done")
        Else
        Response.Write("failed")
        End If
End Sub
</script>
CopyC#
MySQLCmd.txt file content -
INSERT INTO T1 (F_DATE,F_TIME,F_CHARACTER,F_INTEGER,F_TIMESTAMP) VALUES ('2007-11-20','9:11:31','Kwong123',456,'2007-11-20 21:30:29');
INSERT INTO T1 (F_DATE,F_TIME,F_CHARACTER,F_INTEGER,F_TIMESTAMP) VALUES ('2007-12-20','9:11:31','Kwong123',456,'2007-11-20 21:30:29');
INSERT INTO T1 (F_DATE,F_TIME,F_CHARACTER,F_INTEGER,F_TIMESTAMP) VALUES ('2007-09-20','9:11:31','Kwong123',456,'2007-11-20 21:30:29');
Y.dbSilentCmdText="command=UPDATE Daily_Cane SET Car_no=9999,Quota_no=99, Type=99 WHERE Billno=20001 | command=UPDATE Daily_Cane SET Car_no=8888,Quota_no=88, Type=88 WHERE Billno=20002"

x.dbSilentCmdText = "com=INSERT INTO T1 (F_DATE,F_TIME,F_CHARACTER,F_INTEGER,F_TIMESTAMP) VALUES ('2007-11-20','9:11:31','Kwong123',456,'2007-11-20 21:30:29')"

Y.ASPdbExecuteCmd

See Also