DB garbled

xiaoxiao2021-03-06  68

Q. String strsql = "INSERT INTO TBL_GYMUTANGO"; strsql = "(word)"; strsql = "VALUES ('" strkey ")"; -> StrKey is a Chinese character, the program is displayed as garbled. A. Parameters used to solve the garbage string strSql = "INSERT INTO TBL_GYOMUTANGO"; strSql = "(WORD, COMMENT)"; strSql = "VALUES (@ strKey, @ strComment)"; SqlCommand cmd = new SqlCommand (strSql, conn, CMD.Parameters.Add (New SQLParameter ("@ strkey", sqldbtype.varchar, 50)); cmd.parameters.add (New Sqlparameter ("@ strands", sqldbtype.nvarchar, 200)); cmd.Parameters ["@StrKey"]. Value = strkey; cmd.parameters ["@ strands"]. value = strcomment; // sqlcommand cmd = new SQLCOMMAND (strsql, conn); cmd.commandtype = commandType.Text; IRET = CMD. ExecutenonQuery ();

转载请注明原文地址:https://www.9cbs.com/read-109631.html

New Post(0)