Error storing byte in mysql db

Asked

Viewed 72 times

0

I am trying to store what I get in db mysql, however this giving error I think is type of error column:

26/02/2018 09:25:14 User connected
26/02/2018 09:25:14 Login : Skell
26/02/2018 09:25:14 Error: System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info)
   at System.Convert.ToByte(String value)
   at libcomservice.Game.inventory.GetInventoryInfo(Session PLAYER) in D:\SkelletonX\GC\GC IV GC Nexus 2018\GameServer\Server\Request\Tables\Inventory.cs:line 101

line 101 of my code:

RequiredLevel = Convert.ToByte(DBAcess_0.Tables[0].Rows[i]["RequiredLevel"].ToString()), //?

in my table has a column 'Requiredlevel' the type I put as blob, but still error. How can I fix?

1 answer

1

Try using the Encoding.GetBytes()

byte[] bytes = Encoding.ASCII.GetBytes(DBAcess_0.Tables[0].Rows[i]["RequiredLevel"].ToString());

In that reply you can see an example of using the Encoding, converting to byte[] and back to string.

  • and in the column date type I leave as blob ?

  • I believe it’s okay. Since you have an array of bytes, you can save it in a "column blob"

  • @Guilherme, it worked out?!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.