Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2006-10-17 : 02:49:27
|
| hi, here i am trying write a stored procedure in sql server 2005.i am using this sqlserver2005 is back end to asp.net. i am sending two values from asp.net to this stored procedures. i want to insert this two values into the database. i am sending values as parameters.in my .net application i had written: exec dbo.king(" + _id +"," + _id1 +");in sql server i written stored procedure ascreate procedure kingh(@id int,@id1 int)asinsert into details values(id,id1)gobut it is showing error as :The name "id" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.pls correct my errors in this context.thanx in advance,ramuOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-17 : 10:26:50
|
| Isnt it something like this?Con.Execute('EXEC '+@id+','+@id1)where con is connection objectMadhivananFailing to plan is Planning to fail |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-10-17 : 10:38:18
|
The specific error you are seeing is in your stored procedure, it should becreate procedure kingh(@id int,@id1 int)asinsert into details values(@id, @id1) You are not using the parameter names (they include the @ at the beginning), that's why SQL Server thinks you are trying to use column names. |
 |
|
|
pootle_flump
1064 Posts |
Posted - 2006-10-17 : 12:10:21
|
| Another thing to note - it looks like a m:m bridge so it might not apply - that you will need to explicitly define the columns to be inserted into if there are more than two in the target table. Personally I do this in any event as a bit of defensive programming but YMMV. |
 |
|
|
|
|
|
|
|