Question : vb.net find using conaint

hello there,
I am using this code to find a string

If sData.Contains("html") then

how can I add a string like doesn't contain "Error" so it checks that html string and that doesn't have error in the sData string!!

Answer : vb.net find using conaint

I would say that the problem is that your text2insert string has a ' character somewhere in it which is interpreted as the end of the string. Take a simple example of trying to insert the string

String text2insert = "goat's";

Your SQL statement then becomes...

INSERT INTO feedback.html(data) VALUES('goat's');

Hopefully you can easily see how this creates a syntax error.

The normal way that you might approach this is with PreparedStatements, with code like the below...


PreparedStatment stmt = con.prepareStatement("INSERT INTO feedback.html(data) VALUES(?);");
stmt.setBytes(1, text2insert.getBytes());
stmt.execute();

(Note: that I haven't played with BLOB's or MySQL in Java, but my quick research leads me to believe that using a byte[] is the correct way to deal with BLOB columns in MySQL)

This way there are no issues with special characters, escaping, security holes, etc that you get with trying to build your sql string manually.
Random Solutions  
 
programming4us programming4us