473,119 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,119 software developers and data experts.

not permitted in this context

Hi,

I am having a SQL Server 2005 problem with my Insert statement. I am
sending a command via my website to my database. It comes up with an
error I'll put below. The code is here:

"INSERT INTO tblUsers (userName) VALUES ( userNameTest)"

This is the error I get:

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

Now, userName is a varchar field in the database. What is wrong?

Kivak

Jul 19 '06 #1
2 23989

Kivak wrote:
Hi,

I am having a SQL Server 2005 problem with my Insert statement. I am
sending a command via my website to my database. It comes up with an
error I'll put below. The code is here:

"INSERT INTO tblUsers (userName) VALUES ( userNameTest)"

This is the error I get:

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

Now, userName is a varchar field in the database. What is wrong?

Kivak
I'm no expert, so I'm just guessing here, but there are two things I'd
look for. First, is your userNameTest in quotes inside those
parentheses? Second, is there a column in the table that is called
userNameTest?

--Richard

Jul 19 '06 #2
>userName is a varchar field in the database

Columns are in tables, tables are in a database. It is meaningless to
refer to a column without the context of a table. The only table
specified in your sample code is tblUsers, but that is the target of
the INSERT, not a source of data.

The version of INSERT that uses the VALUES clause expects values for a
single new row to be inserted. Those values can be constants, 'John
Smith' or 345, constant expressions, 'John ' + 'Smith' or 300 + 45, or
@variables.

The other version of INSERT replaces the VALUES() clause with a
SELECT. That version will insert as many rows as are returned by the
SELECT. If your purpose was to insert all userName values from
another table into tblUsers this might be the syntax you need:

INSERT INTO tblUsers (userName)
SELECT userNameTest FROM tblTestUsers

Roy Harvey
Beacon Falls, CT

On 18 Jul 2006 20:44:07 -0700, "Kivak" <Li**********@gmail.comwrote:
>Hi,

I am having a SQL Server 2005 problem with my Insert statement. I am
sending a command via my website to my database. It comes up with an
error I'll put below. The code is here:

"INSERT INTO tblUsers (userName) VALUES ( userNameTest)"

This is the error I get:

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

Now, userName is a varchar field in the database. What is wrong?

Kivak
Jul 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: R. Rajesh Jeba Anbiah | last post by:
For a longtime, I'm searching the answer for the error Warning: chmod failed: Operation not permitted in /xxx/xxx/ 'cos I never get success with chmod on the servers I've tried. Now, while...
14
by: @sh | last post by:
Has anyone a function handy that I can apply to various textboxes within a form, each textbox will permit most characters but I want to ban certain characters from each textbox. Therefore I need...
0
by: Jean-Francois Ortolo | last post by:
Hi all I need to know, whether or not any or all of those functions, are being permitted when safe mode is 'On', and the uid/gid of the current directory, is not the same as uid/gid of the...
0
by: fubaba | last post by:
hi, i execute a store procedure got Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.'...
1
by: jenn23 | last post by:
Hi Everyone, I'm trying to figure out what's wrong with this script. Basically there's a form where you can upload a .pdf file or delete it, When I try to delete it I get this: Warning:...
9
by: pbd22 | last post by:
Hi. I am getting the below error: Event Type: Error Event Source: PeskyService Event Category: None Event ID: 0 Date: 1/30/2008 Time: 5:49:10 PM User: N/A
3
by: jideesh | last post by:
---------------trigger code create trigger DeletepurchaseItems on table_purchaseitems for delete,update as begin select * from deleted update table_STOCK set ostock=(ostock-(select sqty from...
8
by: Yew12 | last post by:
Hi, The following code is supposed to stop a booking being made if falls between another bookings start and end date. Unfortunately I get the following error message PLS-00410: duplicate...
5
by: Triple-DES | last post by:
I've seen this question raised more than once, but I have not yet seen a definite, conclusive answer. Consider the following code: struct C { C() {} // might throw }; int main() { try {...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
3
by: efe2023 | last post by:
Hello Everybody, There is SQL Server 2008 R2 database with MS Access front-end (linked ODBC tables). I can see all linked tables in MS Access and can add new rows. However, when trying to update...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: saichinnu1852 | last post by:
I am trying to use Collibra by installing it using AWS Marketplace AMI that they offer and launched the EC2 instance. However, when I try to login to Collibra using the IP Address of the EC2 instance...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.