Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Odd Syntax Error...

Status
Not open for further replies.

grande

Programmer
Feb 14, 2005
657
CA
When running an C# application using iBatis, I'm getting the following syntax error:

"Syntax error converting the varchar value 'Z09' to a column of data type int."

I've searched everywhere, and I can't find the string Z09 in my code or database at all. Does anyone know if Z09 is some sort of special character or something?

Associated code:
Code:
/// <summary>
/// Executes an SQL statement that returns a single row as an Object of the type of
/// the resultObject passed in as a parameter.
/// </summary>
/// <param name="request">The request scope.</param>
/// <param name="session">The session used to execute the statement.</param>
/// <param name="parameterObject">The object used to set the parameters in the SQL.</param>
/// <param name="resultObject">The result object.</param>
/// <returns>The object</returns>
internal object RunQueryForObject(RequestScope request, IDalSession session, object parameterObject, object resultObject )
{
	object result = resultObject;
	
	using ( IDbCommand command = request.IDbCommand )
	{
		using ( IDataReader reader = command.ExecuteReader() )
		{				
			if ( reader.Read() ) //Error happens here
			{
				result = ApplyResultMap(request, reader, resultObject);		
			}
		}

		ExecutePostSelect( session, request);

		RetrieveOutputParameters(request, session, command, parameterObject);
	}
	RaiseExecuteEvent();

	return result;
}

Any help at all (including more info on the error) would be appreciated.

-------------------------
Just call me Captain Awesome.
 
I can think of 2 possible causes:
1) An input Command parameter object is defined as varchar, were the column that the parameter is checked against is actually an int.

2) Or, Command object's SQL statement has casting operations somewhere that raised the exception. Check the query.

Needless to say, it's a DB-side casting exception.
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top