在VS窗体设计中,做的是一个类似QQ聊天的项目,在发消息页面我设置了两个textBox文本框,点击发送按钮时可以将下面的文本框类容传给上面的文本框,我现在想怎么将内容存进数据表中,在数据库中有一个Messages表。这是我的部分代码
private void butEnter_Click(object sender, EventArgs e)
{
//往消息表里面插入消息记录
string msg = string.Format(MSG, this.ID, this.NickName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtNewMsg.Text);
txtMsg.AppendText(msg);
txtNewMsg.Clear(); //因为System.Windows.Forms.Timer是单线程Timer,所以它的精度时53毫秒
} //定义消息格式
private const string MSG = @"{0} {1} {2}
{3}
";
private void butEnter_Click(object sender, EventArgs e)
{
//往消息表里面插入消息记录
string msg = string.Format(MSG, this.ID, this.NickName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtNewMsg.Text);
txtMsg.AppendText(msg);
txtNewMsg.Clear(); //因为System.Windows.Forms.Timer是单线程Timer,所以它的精度时53毫秒
} //定义消息格式
private const string MSG = @"{0} {1} {2}
{3}
";
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货