VB and sql database


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: VB and sql database

  1. #1
    Join Date
    Oct 2007
    Location
    Southern California
    Posts
    10

    VB and sql database

    Hello all. I am a beginner programmer and made an Inventory program to store all of the data scanned in a database. One thing i was able to do was when they scan a UPC, was for the program to update the upc with the item's actual item id before submitting it to the database. the only problem here is if there is no upc in our system, the upc number that was scanned no longer stays in the text box. Here is what my code looks like for the text box.

    thank you in advance

    Code:
    Private Sub item_idtextbox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles item_idtextbox.KeyDown
    
            Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
    
            If e.KeyCode = Keys.Enter Then
    
                Try
                    Me.Inv_mastTableAdapter.FillBy(Me.CommerceCenterImportDataSet.inv_mast, item_idtextbox.Text)
                Catch ex As System.Exception
                    System.Windows.Forms.MessageBox.Show(ex.Message)
                End Try
    
                Me.qohtextbox.Focus()
    
            End If
    
            Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
    
        End Sub

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Moved to .NET
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Oct 2007
    Location
    Southern California
    Posts
    10
    i think i may have gotten somewhere, but i am getting an error.

    Code:
        Private Sub item_idtextbox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles item_idtextbox.KeyDown
    
            Dim novalue As Integer
            novalue = Val(Me.item_idtextbox.Text)
    
            Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
    
            If e.KeyCode = Keys.Enter Then
    
                Try
                    Me.Inv_mastTableAdapter.FillBy(Me.CommerceCenterImportDataSet.inv_mast, item_idtextbox.Text)
                Catch ex As System.Exception
                    System.Windows.Forms.MessageBox.Show(ex.Message)
                End Try
    
                If Me.item_idtextbox.Text = "" Then
                    Me.item_idtextbox.Text = novalue
                End If
                Me.qohtextbox.Focus()
    
            End If
    
            Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
    
        End Sub
    the error is an overload error, which happens if i enter too many digits. for example, a upc is 13 digits, but i can only enter 12 there. and when keydown out of the box, if there are more thant 10 digits, it throws the same error.

  4. #4
    Join Date
    Dec 2004
    Posts
    163
    JoshuaEwing,

    Given the approach you have taken, I would try changing the novalue variable from an Integer to a Long, since I suspect that certain UPC codes will not fit in an integer.

    Kerry Moorman

  5. #5
    Join Date
    Oct 2007
    Location
    Southern California
    Posts
    10
    Kerry, Thank You very much. That worked perfectly. Here is my final code:

    Code:
        Private Sub item_idtextbox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles item_idtextbox.KeyDown
    
            Dim novalue As Long
            novalue = Val(Me.item_idtextbox.Text)
    
            Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
    
            If e.KeyCode = Keys.Enter Then
    
                Try
                    Me.Inv_mastTableAdapter.FillBy(Me.CommerceCenterImportDataSet.inv_mast, item_idtextbox.Text)
                Catch ex As System.Exception
                    System.Windows.Forms.MessageBox.Show(ex.Message)
                End Try
    
                If Me.item_idtextbox.Text = "" Then
                    Me.item_idtextbox.Text = novalue
                End If
    
                If Me.Sales_pricing_unitTextBox.Text = "" Then
                    Me.Sales_pricing_unitTextBox.Focus()
                Else
                    Me.qohtextbox.Focus()
                End If
    
            End If
    
            Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
    
        End Sub

Similar Threads

  1. Replies: 16
    Last Post: 08-22-2007, 07:31 AM
  2. Replies: 1
    Last Post: 02-28-2005, 11:26 AM
  3. Replies: 1
    Last Post: 09-17-2002, 11:57 PM
  4. VB script for SQL database
    By jim in forum VB Classic
    Replies: 1
    Last Post: 02-02-2001, 01:40 PM
  5. SQL server administrative knowledge
    By Becky in forum Database
    Replies: 1
    Last Post: 07-11-2000, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center