| |

VerySource

 Forgot password?
 Register
Search
View: 3863|Reply: 27

Solve the binary conversion problem

[Copy link]

2

Threads

22

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-2-1 23:00:02
| Show all posts |Read mode
code show as below:
SqlCommand cmd = new SqlCommand ("UserIsExict", conn);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add (new SqlParameter ("@ Uid", SqlDbType.Binary, 30));
cmd.Parameters ["@ Uid"]. Value = Encoding.UTF32.GetBytes (paraUid);

cmd.Parameters.Add (new SqlParameter ("@ UserName", SqlDbType.Binary, 30));
cmd.Parameters ["@ UserName"]. Direction = ParameterDirection.Output;

conn.Open ();
cmd.ExecuteNonQuery ();
conn.Close ();

I want to get the value of the parameter "@UserName" in cmd and convert it to string type. The parameter "@UserName" is binary type.
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 France

Post time: 2020-3-18 09:45:01
| Show all posts
string str;
str = cmd.Parameters ["@ UserName"]. value.ToString ();
Reply

Use magic Report

2

Threads

22

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

 Author| Post time: 2020-3-18 10:30:02
| Show all posts
This wo n’t work, you ca n’t get it
Reply

Use magic Report

2

Threads

22

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

 Author| Post time: 2020-3-18 13:15:01
| Show all posts
It seems that the obtained value is empty and cannot be displayed
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 South Africa

Post time: 2020-3-18 19:00:01
| Show all posts
It cannot be converted. . Still can't get
Reply

Use magic Report

2

Threads

22

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

 Author| Post time: 2020-3-18 20:15:01
| Show all posts
Oh, I see, the string displayed after conversion is blank anyway
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-18 21:15:01
| Show all posts
Convert.ToBase64String (inputValue);
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-18 22:30:02
| Show all posts
Convert.FromBase64String (inputValue);
Reply

Use magic Report

0

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-3-19 17:30:02
| Show all posts
ParameterDirection.Output;

To:

 ParameterDirection.ReturnValue;
Reply

Use magic Report

2

Threads

22

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

 Author| Post time: 2020-3-19 17:45:01
| Show all posts
Let me try
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