| |

VerySource

 Forgot password?
 Register
Search
View: 707|Reply: 3

SqlParameterCollection parameter problem

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-7 07:10:01
| Show all posts |Read mode
Adding a parameter a to a sqlcommand, adding a to another command gives the following error:

An unhandled "System.ArgumentException" type exception appears in system.data.dll.

Additional information: Another SqlParameterCollection already contains a SqlParameter with ParameterName "@a".



I want to add the same parameter to multiple commands.
Reply

Use magic Report

0

Threads

8

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-11 10:36:01
| Show all posts
The specific code posted may be a problem with the sqlCommand definition.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-21 08:09:01
| Show all posts
I have encountered the same problem, such as: a parameter is called in more than two places.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Canada

Post time: 2020-1-29 11:36:01
| Show all posts
If several parameter values ​​are the same, define it once.
If it is different, add a sentence sql_command.Parameters.Clear () after running sqlcommand each time.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list