我想在mysql中存储以下表情
Emoticons Score
%-( , -1
%-) , 1
(-: , 1
:*( , -1
这是逗号分隔的文件。
我写了下面的代码来读取这个文件
private void button1_Click(object sender, EventArgs e)
{
string[] lines = File.ReadAllLines("D:\\EmoticonLookupTable.txt");
foreach (var line in lines)
{
var data = line.Split(new[] { ',' }, 2);
string Emoticons = data[0].Trim();
int Score = int.Parse(data[1].Trim());
StoreRecord( Emoticons,Score);
}
}
private void StoreRecord(string word,int Score)
{
var conStr = "server=localhost; database=zahid; password=zia; User Id=root;";
using (var connection = new MySqlConnection(conStr))
using (var command = connection.CreateCommand())
{
connection.Open();
command.CommandText =
@"INSERT INTO za
(Emoticons,Score)
VALUES
(@Emoticons,@Score)";
command.Parameters.AddWithValue("@Emoticons", Emoticons);
command.Parameters.AddWithValue("@Score", Score);
command.ExecuteNonQuery();
}
}
但是这段代码给出了以下错误。
第 1 行的“分数
”列的值超出范围,
感谢提前...