Today a little tool that USES is bcb6 and mysql, using ADO to connect to the database,
Connstr=Provider=MSDASQL. 1; Persist Security Info=False; Data Source=db;
In q1 - & gt; ExecSQL (); Insert to insert into library, tip error, an error is
[MySQL] [ODBC Driver 5.1] [mysqld - 5.1.26 - rc - community] Incorrect string value: '\ xB5 \ xA5 \ xC1 \ xA3 t... 'for column' ftpfile 'at row 1
In CSDN found above, say Chinese problem, want to ask is there any way to solve this problem, thank you
CodePudding user response:
Give yourself up, looking forward to the solution of the master
CodePudding user response:
Tracking program, look at your SQL tone if you have any questions, mind directly send the source code
CodePudding user response:
You check the inserted into the database field whether or not the charset utf8 or type in Chinese, if not, will go wrong
CodePudding user response:
Q1 - & gt; SQL - & gt; The Clear ();
Q1 - & gt; SQL - & gt; Add (" insert into import_wlm_task (ftpfile cmpno, loginuser, uploadtime "
", taskno, boxcnt bigpacklen, smallpacklen) values (: : v1, v2, v3, : v4, : v5, : v6, : v7, : v8) ");
AnsiString filename=StrPas (FDS [1]. The c_str ());
The Log - & gt; Lines - & gt; Add (filename ":" + filename);
Q1 - & gt; The Parameters - & gt; ParamByName (" v1 ") - & gt; Value=https://bbs.csdn.net/topics/filename;
String cmpno=StrPas (FDS [2]. The c_str ());
Q1 - & gt; The Parameters - & gt; ParamByName (" v2 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [2]. C_str ());
Q1 - & gt; The Parameters - & gt; ParamByName (" v3 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [3]. The c_str ());
TDateTime now=now ();
Q1 - & gt; The Parameters - & gt; ParamByName (" v4 ") - & gt; Value=https://bbs.csdn.net/topics/FormatDateTime (" yyyy - - dd hh: mm nn: ss ", now);
String taskno=cmpno + FormatDateTime (" MMDDHHNNSS ", now);
Q1 - & gt; The Parameters - & gt; ParamByName (v5) - & gt; Value=https://bbs.csdn.net/topics/taskno;
Q1 - & gt; The Parameters - & gt; ParamByName (" v6 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [4]. C_str ());
Q1 - & gt; The Parameters - & gt; ParamByName (" v7 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [5]. C_str ());
Q1 - & gt; The Parameters - & gt; ParamByName (" v8 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [6]. C_str ());
Q1 - & gt; ExecSQL ();
CodePudding user response:
reference scoredhigh reply: 3/f you check inserted into the database field whether or not the charset utf8 or type in Chinese, if not, will go wrong Database field using gb2312, if change the database field to utf8, BCB small program won't be an error, but shows in the inside of the database table is garbled, CodePudding user response:
reference 4 floor znit2003 response: q1 - & gt; SQL - & gt; The Clear (); Q1 - & gt; SQL - & gt; Add (" insert into import_wlm_task (ftpfile cmpno, loginuser, uploadtime " ", taskno, boxcnt bigpacklen, smallpacklen) values (: : v1, v2, v3, : v4, : v5, : v6, : v7, : v8) "); AnsiString filename=StrPas (FDS [1]. The c_str ()); The Log - & gt; Lines - & gt; Add (filename ":" + filename); Q1 - & gt; The Parameters - & gt; ParamByName (" v1 ") - & gt; Value=https://bbs.csdn.net/topics/filename; String cmpno=StrPas (FDS [2]. The c_str ()); Q1 - & gt; The Parameters - & gt; ParamByName (" v2 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [2]. C_str ()); Q1 - & gt; The Parameters - & gt; ParamByName (" v3 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [3]. The c_str ()); TDateTime now=now (); Q1 - & gt; The Parameters - & gt; ParamByName (" v4 ") - & gt; Value=https://bbs.csdn.net/topics/FormatDateTime (" yyyy - - dd hh: mm nn: ss ", now); String taskno=cmpno + FormatDateTime (" MMDDHHNNSS ", now); Q1 - & gt; The Parameters - & gt; ParamByName (v5) - & gt; Value=https://bbs.csdn.net/topics/taskno; Q1 - & gt; The Parameters - & gt; ParamByName (" v6 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [4]. C_str ()); Q1 - & gt; The Parameters - & gt; ParamByName (" v7 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [5]. C_str ()); Q1 - & gt; The Parameters - & gt; ParamByName (" v8 ") - & gt; Value=https://bbs.csdn.net/topics/StrPas (FDS [6]. C_str ()); Q1 - & gt; ExecSQL (); I think I know, you use a parameter that I met before, do not use parameters, probably an error when using the parameters of the Chinese CodePudding user response:
AnsiString SQL; SQL="insert into import_wlm_task (ftpfile cmpno, loginuser, uploadtime" ", taskno, boxcnt bigpacklen, smallpacklen) values (' "+ filename +" ',... ) "; Q1 - & gt; SQL - & gt; The Clear (); Q1 - & gt; SQL - & gt; Add (SQL); Q1 - & gt; ExecSQL (); Similar this kind of form is more good CodePudding user response:
Change the server and client character set to the same and have a look CodePudding user response:
Custom install mysql database, select the character set for GB2312 With navicat for mysql management tool to create the database Can be solved, CodePudding user response:
references 9 f cptang response: custom install mysql database, select character set for the GB2312 With navicat for mysql management tool to create the database Can be solved, this way I've tried, not yo, CodePudding user response:
references to the tenth floor znit2003 response: Quote: references 9 f cptang response: Custom install mysql database, select the character set for GB2312 With navicat for mysql management tool to create the database Can be solved, this way I've tried, not yo, I said of that kind of way, one hundred percent can ah, If you use a parameter, the corresponding field assignment with conversion function, such as Q1 - & gt; The Parameters - & gt; ParamByName (" v1 ") - & gt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull