Connecting Tech Pros Worldwide Help | Site Map

SQL server 2005 problem

Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 13 '09
Hey guys was up

can any one help me

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

Expand|Select|Wrap|Line Numbers
  1.   Dim objCmdins As New SqlCommand("Insert into pay(payment_mode) values(" & temp & "')'", objConn)
  2.   objCmdins.CommandType = CommandType.Text
  3.   objCmdins.ExecuteNonQuery()
  4.  
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
Newbie
 
Join Date: Jun 2009
Location: Whitehall, PA
Posts: 7
#2: Sep 15 '09

re: SQL server 2005 problem


You appear to be missing the opening single quote before " & temp, so ATM rather than 'ATM' appears in your VALUES list.
Newbie
 
Join Date: Sep 2009
Posts: 2
#3: Sep 15 '09

re: SQL server 2005 problem


THX ryachza issue resolved
Reply