如何从数据库读取数据到文本框 [英] How to read data from DataBase to TextBox

查看:98
本文介绍了如何从数据库读取数据到文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我需要从TextBox的DataSet表中读取数据.

该数据集可与XML一起使用.

我不想使用DataBindings

如果您需要更多信息,请告诉我...

谢谢

Hello
I need read data from a table of a DataSet for a TextBox.

The DataSet works with XML.

I don''t want to do with DataBindings

If you need more info, just tell me...

Thanks

推荐答案

DataSet ds=new DataSet();
DataSet ds = new DataSet();
//read the xml file to dataset
ds.ReadXml(Server.MapPath("XML.xml"));
//get the value to text box
TextBox1.Text=ds.Tables[0].Rows[0][0].ToString();


// Mention System.IO for access FileStream class
FileStream fs = new FileStream("FilePath", FileMode.Open);

//Mention System.Data for access Dataset and Datatable class 
        DataSet ds = new DataSet();
        ds.ReadXml(fs);  // read XML schema 
// Use a DataTable to display the members.
DataTable dt = ds.Tables["member"];

textbox.Text = dt.Rows[row][col].ToString() // binding textbox to specified rows


数据集ds = new数据集( );
sqldataAdapter sda = new sqldataAdapter(从表名中选择*",connectionString);
sda.fill(ds,"TableName");
datarow dro = ds.Table ["tableName"].row [0];
textbox.text = dro.ItemArray.getValue(0);
dataset ds=new dataset();
sqldataAdapter sda=new sqldataAdapter("select * from tablename",connectionString);
sda.fill(ds,"TableName");
datarow dro=ds.Table["tableName"].row[0];
textbox.text=dro.ItemArray.getValue(0);


这篇关于如何从数据库读取数据到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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