调试的时候正常,正常运行的时候画面就卡住了没法往下进行了,谁能告诉我为什么? 急啊!!!
private void btnSend_Click(object sender, EventArgs e){
int result = -1;
if (rtxtChat.Text=="")
{
MessageBox.Show("消息内容不能为空","输入提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else if (rtxtChat.Text.Length>300)
{
MessageBox.Show("消息文本过长请分段输入","输入提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
string formatGut = rtxtChat.Rtf.ToString();
string messageGut = formatGut.Replace("'", "''"); //替换‘ 为 ’‘
string sql = string.Format(
"INSERT INTO Messages(FromUserId,ToUserId,Message,MessageTypeId,MessageState) VALUES({0},{1},'{2}',{3},{4})",
UserHelper.loginId,friendId,messageGut,1,0);
try
{
SqlCommand command = new SqlCommand(sql, DBHelper.connection);
DBHelper.connection.Open();
result=command.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误提示1");
}
finally
{
DBHelper.connection.Close();
}
if (result != 1)
{
rtxtInfo.Text += string.Format("消息“{0}”发送出现异常,请尝试重新发送.\n", rtxtChat.Text);
}
else
{
string sendGut = rtxtChat.Rtf.ToString();
rtxtInfo.SelectionColor = Color.FromArgb(101, 119, 64);
rtxtInfo.AppendText(UserHelper.nickName + " " + System.DateTime.Now.ToString() + "\n");
rtxtInfo.SelectedRtf = sendGut;
//rtxtInfo.Text += sendGut;
}
rtxtChat.Text = "";
}
}
上面的方法是模仿QQ的传送图片和带字体颜色的传送,正常运行的时候传字体可以,但是发图片的时候就卡住了
谁能告诉我是为什么呢急啊!!
我的message列的数值类型是text型的够大了吗?
--------------------编程问答-------------------- 你写了个死循环 --------------------编程问答-------------------- 用BINARY类型吧,还有,你怎么将图片转成其他形式的? --------------------编程问答-------------------- 没有啊,调试运行的时候就可以没有什么问题
直接打开exe文件时就(程序没有反应)的时候的结果 --------------------编程问答-------------------- string formatGut = rtxtChat.Rtf.ToString(); //就是这句 转为string型
string messageGut = formatGut.Replace("'", "''"); //替换‘ 为 ’‘
--------------------编程问答-------------------- 我顶!!!
补充:.NET技术 , C#