• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

VB6 - Execute Update Statement

Good Day Experts!

I am trying to understand what is happening at the end of this line of code so I can translate it to VB.Net.  

Here is the line:
SQLconn99.Execute ("Update [PROCESSING] SET [MISROUTE ROUTED CARRIER] ='BILL OK',[MISROUTE ROUTED COST] = 0  WHERE [PRO NUMBER]='" & pdoxRS(0) & "' AND [PRO CODE]='" & pdoxRS("PRO CODE") & "' AND [PRO OCCURRENCE]=" & pdoxRS("PRO OCCURRENCE") & " AND [SCAC]='" & pdoxRS("SCAC") & "'"), intRecsAffected

I have been unable to find a structure definition for what "intRecsAffected"  is at the end of the statement.

I have to convert this to VB.Net so I am trying to understand.  

Thanks,
jimbo99999
0
Jimbo99999
Asked:
Jimbo99999
3 Solutions
 
John (Yiannis) ToutountzoglouCommented:
RecordsAffected
Optional. A Long variable to which the provider returns the number of records that the operation affected.
see.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms675023(v=vs.85).aspx
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
CodeCruiserCommented:
>You better use ExecuteNonQuery

Which will return you the intRecsAffected number(number of rows affected).
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Jimbo99999Author Commented:
Thanks, I am trying this morning to get this converted.
0
 
John (Yiannis) ToutountzoglouCommented:
if you are using sql Server this might be you code...
 Dim conn As New SqlConnection("MyProjectConnectionString")
        If conn.State = ConnectionState.Open Then conn.Close()
        conn.Open()

        Dim StrSql As String = "Update [PROCESSING] SET [MISROUTE ROUTED CARRIER] ='BILL OK',[MISROUTE ROUTED COST] = 0  WHERE [PRO NUMBER]=@pdoxRS1 AND [PRO CODE]=@pdoxRS2 AND [PRO OCCURRENCE]=@pdoxRS3 AND [SCAC]=@pdoxRS4"
        Dim SqlCmd As New SqlCommand(StrSql, conn)

        'parameters
        Dim Parameter1 As New SqlParameter("@pdoxRS1", pdoxRS(0))
        Dim Parameter2 As New SqlParameter ("@pdoxRS2",pdoxRS(PRO CODE))
        Dim parameter3 As New SqlParameter ("@pdoxRS3",pdoxRS(PRO OCCURRENCE))
        Dim parameter4 As New SqlParameter("@pdoxRS4", pdoxRS(SCAC))

        'add parameter to command
        SqlCmd.Parameters.Add(Parameter1)
        SqlCmd.Parameters.Add(Parameter2)
        SqlCmd.Parameters.Add(Parameter3)
        SqlCmd.Parameters.Add(parameter4)


        Dim intRowsAffected = SqlCmd.ExecuteNonQuery

        conn.Close()
        SqlCmd.Dispose()
        conn.Dispose()
        GC.Collect()

Open in new window

0
 
Jimbo99999Author Commented:
Thanks for the reference and info to duplicate.  Another item for the back pocket as I continue in this learning process.

jimbo99999
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now