April 29, 2011 at 6:45 am
Alright, so I have some VB.net code that is querying a SQL Server 2000 db utilizing the SqlCommand.ExecuteScalar method.
An example of the query I'm trying to actually run:
SELECT [Col1] FROM [TableName] WHERE [TableName].[PKey] = @[PKey]
(These obviously aren't my actual field/table names.)
[Col1] is a varchar field
[PKey] is numeric(18,0) field
@PKey is obviously a parameter that I'm defining in my VB.net code using .net's SqlParameter object.
When I set the parameter up I give it ParameterName = '@Pkey', SqlDbType = Int, Value = (Value pulled from somewhere else, a six digit number typically).
There are no text, ntext, or image data types anywhere to be found. Additionally nowhere in that entire table is there such a datatype. If I run the query in SQL Server it doesn't have this problem at all, but when I call it from VB.net code it is returning this SqlException.
I've been banging my head against the wall with this for a little while, and can't find any reason for this behavior in my VB.net code so am wondering if it is something on the database end. FWIW I have many, many places in this project and many other projects I have worked on where I use this exact sort of thing and have never had this issue.
May 3, 2011 at 7:10 pm
"= @[PKey]" - is it the actual syntax?
_____________
Code for TallyGenerator
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply