Select the product you need help with
Error message occurs in SQL Server 7.0 when you call the Command.Prepare method before you add parameters by using Visual C# .NET: "An unhandled exception of type"Article ID: 311348 - View products that this article applies to. This article was previously published under Q311348
For a Microsoft Visual Basic .NET version of this article, see 310368
(http://support.microsoft.com/kb/310368/
)
.
This article refers to the following Microsoft .NET Framework Class Library namespaces:
On This PageSYMPTOMS When you create a parameterized command against Microsoft
SQL Server 7.0, if you call the Prepare method before you add parameters to the command, you receive the
following error message: An unhandled exception of type
'System.Data.SqlClient.SqlException' occurred in system.data.dll. Additional information: System error. CAUSE This problem occurs in SQL Server 7.0 because, by design,
you cannot run the Prepare method before you add parameters. This applies to most database
systems. SQL Server 2000 does not generate the above-mentioned exception because it does not run Prepare until the first command is executed. This optimization prevents the overhead of Prepare if no commands are subsequently executed. RESOLUTION To resolve this problem, do not call the Prepare method until after you add the parameters. MORE INFORMATIONSteps to reproduce the behaviorThe sample code to follow uses the Region table of the Northwind sample database.
REFERENCES For more information on ADO.NET objects and syntax, refer
to the following Microsoft .NET Framework Software Development Kit (SDK)
documentation:
Accessing Data with ADO.NET http://msdn2.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx
(http://msdn2.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx)
PropertiesArticle ID: 311348 - Last Review: May 13, 2007 - Revision: 3.8 APPLIES TO
|


Back to the top








