如何在Windows窗体应用程序中将richtextbox绑定到sql server数据库 [英] how to bind richtextbox to sql server database in windows form application
本文介绍了如何在Windows窗体应用程序中将richtextbox绑定到sql server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在sqlserver数据库中有一个表,并且我想要绑定到richtextbox的列的特定单元格值。
代码是:
I have a table in sqlserver database and a particular cell value of a column I want to bind to a richtextbox.
code is:
void fun4explaination(string sql)
{
try
{
BindingSource ebsource = new BindingSource();
SqlDataAdapter dae;
string connectionString = "data source=rakesh-PC;initial catalog=mysoftdb;user id=sa;password=ruhil";
SqlConnection conne = new SqlConnection(connectionString);
dae = new SqlDataAdapter(sql, conne);
conne.Open();
DataSet dse = new DataSet();
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dae);
dae.Fill(dse, "dictionary");
ebsource.DataSource = dse.Tables["dictionary"];
richTextBox4.DataSource = ebsource; //problem is here
richTextBox4.DisplayMember = "explanation";
richTextBox4.ValueMember = "explanation";
conne.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
请帮我
pls help me
推荐答案
RichTextBox没有DataSource,DisplayMember或ValueMember。这是一个文本框。
RichTextBox does not have DataSource, DisplayMember or ValueMember. It is a textbox.
这篇关于如何在Windows窗体应用程序中将richtextbox绑定到sql server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文