如何使用visual studio 2013将我的richtextbox保存到mysql数据库表中? [英] How do I save my richtextbox into mysql database table using visual studio 2013?

查看:104
本文介绍了如何使用visual studio 2013将我的richtextbox保存到mysql数据库表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,如果有人关心,请尝试帮助。

这个我使用它的代码是VB,形式是WPF,其中嵌入了我的rtbQuestion。错误是在带下划线的代码下产生的:它说:'document'不是system.windows.forms.richtextbox的成员;

但我已经导入了这个声明:在上面导入system.windows.document。谢谢。



我的尝试:



Hello, if anyone cares, try to help please.
this the code my using it is in VB and the form is WPF where my rtbQuestion is embedded. The error is produced under the underlined code: it says: 'document' is a not a member of system.windows.forms.richtextbox;
yet i have imported the statment: imports system.windows.document on top. Thanks.

What I have tried:

Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
    Dim conn As MySqlConnection = New MySqlConnection(con.ConnectionString)
    Dim command As MySqlCommand = conn.CreateCommand
    Dim richText As String = New TextRange(rtbQuestion.document.ContentStart, rtbQuestion.document.contentend) + Text
    Dim s As String = WebUtility.HtmlEncode(richText)
    command.Parameters.AddWithValue("@s", s)
    command.CommandText = "insert into proc_tra (procedures) values (@)"
    conn.Open()
    command.ExecuteNonQuery()
    conn.Close()
End Sub

推荐答案

As你可以看到 RichTextBox类(System.Windows。表格) [ ^ ]没有文档属性。
As you can see the RichTextBox Class (System.Windows.Forms)[^] does not have a Document property.


大家好,非常感谢。我正在寻找类似的东西



Hi guys, thank you very much. I was looking for something similar to this

Private Sub rtbSave_Click(sender As Object, e As EventArgs) Handles rtbSave.Click
    Const connStr As String = "Server=localhost; username=root; password=1212;database=rtyum"
    Dim rtfRecordId As Byte
    Dim RicherID As Integer
    Dim conn As MySqlConnection = New MySqlConnection(connStr)
    Try
        conn.Open()
        Const insQuery As String = "INSERT INTO richetext (RichID, RicText) VALUES (@RID, @RTF)"
        Dim cmd As MySqlCommand = New MySqlCommand(insQuery, conn)
        cmd.Parameters.Add(New MySqlParameter("@RID", MySqlDbType.Int32)).Value = RicherID
        cmd.Parameters.Add(New MySqlParameter("@RTF", MySqlDbType.VarBinary)).Value = System.Text.Encoding.ASCII.GetBytes(RichTextBox1.Rtf)
        rtfRecordId = Convert.ToByte(cmd.ExecuteScalar)
        'rtfRecordId = Convert.ToString(cmd.ExecuteScalar)
        'RichTextBox1.Rtf = RichTextBox1.ToString()
        MessageBox.Show("Data Successfully Saved")
    Catch ex As Exception
        MessageBox.Show("Data Not Saved")
    End Try
End Sub


这篇关于如何使用visual studio 2013将我的richtextbox保存到mysql数据库表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆