How can I store a string in a varbinary(max) column?
I’m havig trouble in the convertion process
i’m doing this:
cmd.CommandText = "Insert into " + bdcombo.Text + ".dbo.nomes (id, nome) values (@id, @nome)";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlcon;
cmd.Parameters.Add("@nome", SqlDbType.VarBinary, 20).Value = Convert.ToSByte(textBox1.Text);
If you want to store a string, use [n]varchar(max).
If you must use varbinary(max), then to get the bytes you must use an encoding, for example:
and later:
(when reading)