SQL server 2005 problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mastiandchill
    New Member
    • Sep 2009
    • 2

    SQL server 2005 problem

    Hey guys was up

    can any one help me

    when i try to run the follwing SQL command in VB.net

    Code:
      Dim objCmdins As New SqlCommand("Insert into pay(payment_mode) values(" & temp & "')'", objConn)
      objCmdins.CommandType = CommandType.Text
      objCmdins.ExecuteNonQuery()
    i get the error

    The name "ATM" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

    where pay is a table in SQL server 2005
    Payment_mode is column of type ntext
    temp is string with value ATM
    Last edited by Frinavale; Sep 15 '09, 06:50 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • ryachza
    New Member
    • Jun 2009
    • 7

    #2
    You appear to be missing the opening single quote before " & temp, so ATM rather than 'ATM' appears in your VALUES list.

    Comment

    • mastiandchill
      New Member
      • Sep 2009
      • 2

      #3
      THX ryachza issue resolved

      Comment

      Working...