简体   繁体   中英

Replace OracleCommand by SqlCommand [C#/ASP.NET]

I have to replace an OracleCommand by a SqlCommand in my code in the context of a database migration. In my code, I have the use of myOracleCommand.BindByName = true; . The property BindByName doesn't exist in the class SqlCommand so I was wondering if the SqlCommand is 'bindbyname by default' when it comes to parameters and I could thus just delete this line.

You can ignore/not transfer that line ( BindByName = true )

Parameters can only be bound by name in SqlCommand and never by position (which is what happens when you set BindByName = true in the OracleCommand ).


You will have to change all the parameter names in both the query and possibly the SqlParameter instances as well.

In Oracle its :paramName , in sql server its @paramName . The parameter name in the SqlParameter instance can start with @ or not, if not it will be added by the command when the execution occurs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM