Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Go Back  Xtreme Visual Basic Talk > > > Sql Update statement with parameters for MS Access


Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2014, 01:59 PM
jotol jotol is offline
Newcomer
 
Join Date: Nov 2012
Posts: 5
Default Sql Update statement with parameters for MS Access


Hi, can any one help with the following codes.
I get an exception error code telling me that
one of the require parameters are empty.
HTML Code:
     query = "UPDATE TRUNK_INVENTORY SET Part_Number= ?, Description= ?, Analyzer= ?, Trunk_Location= ?, Qty_On_Hand= ?," & _
                    "Inventory_Count= ?, Last_Entry_Date=? WHERE Part_Number= ?"
            Dim cmd As OleDbCommand = New OleDbCommand(query, MiConexion)

                cmd.CommandType = CommandType.Text

                
                cmd.Parameters.AddWithValue("Part_Number", txtPartNumber)
                cmd.Parameters.AddWithValue("Description", txtDescription.Text)
                cmd.Parameters.AddWithValue("Analyzer", txtAnalyzer.Text)
                cmd.Parameters.AddWithValue("Trunk_Location", txtTrunLocation.Text)
                cmd.Parameters.AddWithValue("Qty_On_Hand", txtQtyOnHand.Text)
                cmd.Parameters.AddWithValue("Inventory_Count", txtInventoryCount.Text)
                cmd.Parameters.AddWithValue("Last_Entry_Date", txtLastUpdate.Text)

                cmd.ExecuteNonQuery()
                MsgBox("Part Number was Updated")
            Catch ex As Exception
                MessageBox.Show(ex.Message & " - " & ex.Source)
            End Try
Reply With Quote
  #2  
Old 11-23-2014, 06:38 AM
PlausiblyDamp's Avatar
PlausiblyDampSql Update statement with parameters for MS Access PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

IIRC the parameter names need to be prefixed with an @ symbol when you add them using the .AddWithValue method, even though OleDB doesn't support named parameters anyway!
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 11-25-2014, 11:06 AM
sanu sanu is offline
Newcomer
 
Join Date: Nov 2014
Posts: 2
Default

cmd.Parameters.AddWithValue("Part_Number", txtPartNumber)
Your exception has been generated from the underlined portion of the above Codes.
It should be cmd.Parameters.AddWithValue("Part_Number", txtPartNumber.Text)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
 
Sql Update statement with parameters for MS Access
Sql Update statement with parameters for MS Access
 
-->