Incorrect syntax near...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Incorrect syntax near...

Hybrid View

  1. #1
    Join Date
    Nov 2006
    Posts
    29

    Question Incorrect syntax near...

    Okay i am growing weary of staring. I keep getting incorrect syntax near 'usp_bldgs_c' I cannot figure out what that is. Please help!

    Code:
    Private Sub AddNewRecord(ByVal bldgdesc As String)
    
            Dim conString As String = Utilities.GetConnectionString("AssetInventory")
            Dim conInventory As SqlConnection = New SqlConnection(conString)
            Dim cmdStoredProc As SqlCommand
    
    
            cmdStoredProc = New SqlCommand("usp_bldgs_c", conInventory)
            cmdStoredProc.Parameters.AddWithValue("@bldg_desc", bldgdesc)
    
            conInventory.Open()
    
            cmdStoredProc.ExecuteNonQuery()
    
            conInventory.Close()
    
            BindBldg(bldgdesc)
        End Sub 'AddNewRecord

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Try setting cmdStoredProc's .CommandType property to CommandType.StoredProcedure.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Aug 2007
    Location
    London
    Posts
    73
    Yaa try to put
    Code:
    cmdStoredProc.CommandType = CommandType.StoredProcedure
    cmdStoredProc.CommandText = "usp_bldgs_c"
    cmdStoredProc.Parameters.Add(New SqlParameter("@bldg_desc", bldgdesc))

    try to do like this....

  4. #4
    Join Date
    Nov 2006
    Posts
    29

    Question

    I did this and it worked wonderfully, however now I am doing the UpdateRecord and it's saying the same thing

    Code:
    Private Sub UpdateRecord(ByVal bldgid As Integer, ByVal bldgdesc As String)
    
            Dim conString As String = Utilities.GetConnectionString("AssetInventory")
            Dim conInventory As SqlConnection = New SqlConnection(conString)
            Dim cmdStoredProc As SqlCommand
    
            cmdStoredProc = New SqlCommand("usp_bldgs_u", conInventory)
            cmdStoredProc.CommandType = CommandType.StoredProcedure
            cmdStoredProc.Parameters.AddWithValue("@bldg_id", bldgid)
            cmdStoredProc.Parameters.AddWithValue("@bldg_desc", bldgdesc)
    
            conInventory.Open()
    
            cmdStoredProc.ExecuteNonQuery()
    
            conInventory.Close()
    
            BindBldg()

  5. #5
    Join Date
    Aug 2007
    Location
    London
    Posts
    73
    Code:
    Private Sub UpdateRecord(ByVal bldgid As Integer, ByVal bldgdesc As String)
    
           Dim conString As String = Utilities.GetConnectionString("AssetInventory")
            Dim conInventory As SqlConnection = New SqlConnection(conString)
            Dim cmdStoredProc As new SqlCommand
    
            cmdStoredProc.CommandType = CommandType.StoredProcedure
            cmdStoredProc.CommandText = "usp_bldgs_c"
            cmdStoredProc.Parameters.AddWithValue("@bldg_id", bldgid)
            cmdStoredProc.Parameters.AddWithValue("@bldg_desc", bldgdesc)
    
            conInventory.Open()
    
            cmdStoredProc.ExecuteNonQuery()
    
            conInventory.Close()
    
            BindBldg()

    try like this..may the order was wrong...
    u declared this
    cmdStoredProc.CommandType = CommandType.StoredProcedure

    after the passing the name of the SP.

Similar Threads

  1. Incorrect syntax near the keyword 'UNION'. "
    By yasinirshad in forum Database
    Replies: 3
    Last Post: 08-14-2007, 08:55 AM
  2. Incorrect Syntax near '='
    By Matrix.net in forum Database
    Replies: 0
    Last Post: 03-28-2007, 10:36 AM
  3. Replies: 5
    Last Post: 04-09-2006, 08:28 PM
  4. Incorrect syntax near 'collate'
    By Daryl in forum Database
    Replies: 0
    Last Post: 03-01-2002, 01:08 PM
  5. Incorrect syntax near '#IND'
    By Mario in forum Database
    Replies: 2
    Last Post: 07-29-2000, 07:45 AM

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