Results 1 to 2 of 2

Thread: Record Exist? Problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    293

    Exclamation Record Exist? Problem

    The Following code i am using at the moment is to ADD (only) to a database.

    Code:
            Dim connection As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = ..\db1.mdb")
            Dim command As New OleDbCommand("INSERT INTO Table1 (Barcode, Box, Description, Whos) VALUES (@Barcode, @Box, @Description,@Whos)", connection)
            command.Parameters.AddWithValue("@Barcode", txtBarcode.Text)
            command.Parameters.AddWithValue("@Box", txtBox.Text)
            command.Parameters.AddWithValue("@Description", rttDetail.Text)
            command.Parameters.AddWithValue("@Whos", txtWho.Text)
            connection.Open()
            command.ExecuteNonQuery()
            connection.Close()
    But what i need before it adds it to the database is too check the Barcode column to see if what is typed in the txtbarcode.text textbox matches anything in the barcode column in the DB. if it does a messagebox appears to tell them if not carry on.

    any help is helpful

    thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Record Exist? Problem

    Don't post the same question in multiple forums.

    http://www.vbforums.com/showthread.php?t=524583
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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