Results 1 to 1 of 1

Thread: Update table through User Argument

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2011
    Posts
    2

    Update table through User Argument

    Hi I'm new on VB code,
    I'm working on Fast-Reporting tool as its very rare not known in the market.
    The existing report taking argument of visit no and need to update the correct reference number both Argumetn should pass before run the report.
    The following code already return could you please help me , so the columns

    Customer reference value update to = 48000098437
    and the VisitID = 4146832

    UPDATE tblVisit SET CustomerReference = '4800098437' WHERE VisitID = 4146832
    I can do through SQL but through VB I don't know the existing code shown belwo:

    Code:
    Namespace FastReport
      Public Class ReportScript
    
        Private myConn As SqlConnection
        Private myCmd1 As SqlCommand
        Private myCmd2 As SqlCommand
        'Private myReader As SqlDataReader
        'Private results As String
        Dim connectionString As String = "Server=
        
        Private Sub btnOk_Click(ByVal sender As Object, ByVal e As EventArgs)
    
          Dim VisitIDString AS String   
          Dim VisitIDsUpdated As Object
          Dim myComma() As Char = {","}
          
          '------------------------------------------------------------------------------------------------------------
          VisitIDString = VisitIDTextBox.Text
          VisitIDString = VisitIDString.Replace(vbCr, "").Replace(vbLf, ",")
          '      VisitIDString = VisitIDString.Replace(",", "")      
          VisitIDString = VisitIDString.Replace(" ", "")
        MsgBox(VisitIDString.Replace(vbCr, "").Replace(vbLf, ","))  
          VisitIDString = VisitIDString.TrimEnd(MyComma)
          
          Report.SetParameterValue("VisitIDByte",VisitIDString) 
         MsgBox(VisitIDString)   
          '------------------------------------------------------------------------------------------------------------
          
          'Create a Connection object 
          myConn = New SqlConnection(connectionString)
    
          'Create a Command object 
          myCmd1 = myConn.CreateCommand
          myCmd1.CommandText = "UPDATE tblVisit SET Invoiced = 1 WHERE VisitID IN (" & VisitIDString & ")"
          'Open the connection.
          myConn.Open()
    
          'Execute the statement and return a single value. If you wanted to return more than 1 value you need to add a loop here.  
          
          VisitIDsUpdated = myCmd1.ExecuteScalar()
                
          'Close the database connection.
          myConn.Close()    
          
        End Sub    
     
      
    
        Private Sub Label3_Click(ByVal sender As object, ByVal e As EventArgs)
          
        End Sub
    
        Private Sub TextBox1Ref_Click(ByVal sender As object, ByVal e As EventArgs)
          
        End Sub
      End Class
    End Namespace
    Last edited by imfarhan; Sep 13th, 2017 at 03:19 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width