.Net SqlProcedure Help.

Jan 17, 2008



I am getting a Must declare the table variable "@TableName" exception on this method and Im not sure why.


This is my commandText before I insert my parameters.


Code Block


Dim historyRecordCommand As String = "SELECT * FROM @TableName WHERE dbo.GetPrimaryKeyColumnName(@TableName)" & _

" = CONVERT(VARCHAR, @Key) AND HistoryRecordCreateDate BETWEEN" & _

" CONVERT(VARCHAR, @StartTime, 21) AND CONVERT(VARCHAR, @EndTime, 21)"





Code Block



Dim historyRecordSqlCommand As SqlCommand = connection.CreateCommand
historyRecordSqlCommand.CommandText = historyRecordCommand
historyRecordSqlCommand.Parameters.AddWithValue("@TableName", rowAccessionSystemLogDetail.TableName)
historyRecordSqlCommand.Parameters.AddWithValue("@Key", rowAccessionSystemLogDetail.TablePrimaryKeyValue)
historyRecordSqlCommand.Parameters.AddWithValue("@StartTime", rowAccessionSystemLogs.StartTime)
historyRecordSqlCommand.Parameters.AddWithValue("@EndTime", rowAccessionSystemLogs.EndTime)

Dim historyRowSqlReader As SqlDataReader = historyRecordSqlCommand.ExecuteReader(CommandBehavior.SingleRow)







I only expect to get 1 row back and I have checked all my values and they are fine also.

Anyone have any ideas?

Thanks

View 5 Replies


ADVERTISEMENT

Can I Keep A Object In Memory Betweek Calls To SqlProcedure?

Feb 25, 2008

I am wondering if it is at all possible to keep an object in memory between calls to a SqlFunction or SqlProcedure.

Every time a row is inserted in to a table, i need to do some processing on the data. The processing becomes many times faster if I can do some preprocessing (the preprocessing is independent of the data inserted into the table). So basically, I want to save the result of the preprocessing, only do it one time, and save the result in a object in memory. Is this at all possible?

Regards, Egil.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved