Solved

VB6 - Execute Update Statement

Posted on 2013-02-07
6
312 Views
Last Modified: 2013-02-08
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
Comment
Question by:Jimbo99999
6 Comments
 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 100 total points
ID: 38865804
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
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 100 total points
ID: 38866458
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 50 total points
ID: 38867347
>You better use ExecuteNonQuery

Which will return you the intRecsAffected number(number of rows affected).
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Jimbo99999
ID: 38868001
Thanks, I am trying this morning to get this converted.
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 38868089
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
 

Author Closing Comment

by:Jimbo99999
ID: 38868576
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB: Convert 2 dates to specific format 24 52
VB.NET 1 28
start a process from a service 3 31
location of a form 2 25
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question