sql - implicit conversion from data type varchar to varbinary is not allowed -


after run program, add data, , message:

implicit conversion data type varchar varbinary not allowed

i watched video on youtube , did same youtuber. works him not me.

i trying add data visual studio sql database:

here's code:

imports system.data.sqlclient select convert(varchar(100), convert(varbinary(max),'0xffd8ffe000')) public class form1  dim conn sqlconnection dim cmd sqlcommand  private sub button1_click(sender object, e eventargs) handles button1.click     conn = new sqlconnection     conn.connectionstring = "data source=byg-a101-moelka;initial catalog=app;integrated security=true"     dim reader sqldatareader      try          conn.open()         dim query string         query = "insert person (id,firstname,lastname,age) values ('" & textbox1.text & "', '" & textbox2.text & "', '" & textbox3.text & "', '" & textbox4.text & "')"          cmd = new sqlcommand(query, conn)         reader = cmd.executereader         messagebox.show("datasaved")          conn.close()      catch ex exception         messagebox.show(ex.message)             conn.dispose()      end try   end sub 

a few problems

executereader should not used insert
use executenonquery

that subject injection attack. use parameters. parameters must match data type of table columns.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -