Results 1 to 1 of 1

Thread: Converting to SPROC

  1. #1

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Converting to SPROC

    How do i convert the code below to Stored Procedure?
    This is in SAVE Button
    Code:
    On Error GoTo ErrHandler
      If Checker = True Then  'Product ID already Exist then save in tblStocktransFile Only
        'SEQ = rsStock.Fields("Sequence")
        oConn.BeginTrans
    
          sSQL = "SELECT IsNull(Max(Sequence),0)+1 " & _
                  "FROM tblStockTransFile " & _
                      "WHERE ProductID='" & txtProdID.Text & "' AND EntryDate=" & DTEntryDate.Value & ""
                      Debug.Print sSQL
          oConn.Execute sSQL
          
          sSQL = "INSERT INTO tblStockTransFile (ProductID, EntryDate, PurchasePrice,Quantity, Reason)" & _
                  "VALUES('" & txtProdID.Text & "'," & DTEntryDate.Value & _
                       ",'" & txtProdPurchasePrice.Text & "','" & txtProdQTY.Text & "','In')"
                      Debug.Print sSQL
                      '" & rsStock.Fields("Sequence") + 1 & "'
          oConn.Execute sSQL
          
        oConn.CommitTrans
      Else  'Product ID does not Exist so save in both tblStockMasterFile and tblStockTransFile
        
        oConn.BeginTrans
          
          sSQL = "INSERT INTO tblStockMasterFile(ProductID, ProductName,Unit,ReOrderPoint)" & _
                    "VALUES( '" & txtProdID.Text & "','" & txtProdName.Text & "','" & txtProdUnit.Text & " ', '" & txtProdReOrderPoint.Text & "')"
          oConn.Execute sSQL
          
          sSQL = "SELECT IsNull(Max(Sequence),0 )+ 1" & _
                  "FROM tblStockTransFile " & _
                      "WHERE ProductID='" & txtProdID.Text & "' AND EntryDate=" & DTEntryDate.Value & ""
                      Debug.Print sSQL
          oConn.Execute sSQL
          
          sSQL = "INSERT INTO tblStockTransFile (ProductID, EntryDate, PurchasePrice, Quantity, Reason)" & _
                    "VALUES('" & txtProdID.Text & "'," & DTEntryDate.Value & ",'" & txtProdPurchasePrice.Text & _
                       "','" & txtProdQTY.Text & " ','In')"
                     '  Debug.Print sSQL
          oConn.Execute sSQL
    
        
        oConn.CommitTrans
        
      End If
    Last edited by Simply Me; Sep 17th, 2007 at 08:51 AM.
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

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