如何在C#中将表数据从Oracle.DataAccess.Client加载到datagridview [英] how to load the table data from Oracle.DataAccess.Client to datagridview in c#
问题描述
我尝试了此编码,但无法正常工作
字符串sql =从smp_try中选择*";
OracleCommand cmd =新的OracleCommand(sql,conn);
cmd.CommandType = CommandType.Text;
OracleDataAdapter da =新的OracleDataAdapter(cmd)
DataTable dt = new DataTable("smp_try");
da.Fill(dt);
我认为一个更简单的选择是使用Visual Studio
的DataSet
设计器生成DataSet
和DataTables
通过AddNewDataSource
向导.在这方面,我认为以下文章可能会有所帮助
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/buildingnetapplications/BuildingNETApplications.htm [ ^ ]
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/dotnet/getstarted-c/getstarted_c_otn.htm [ http://msdn.microsoft.com/zh-CN/library/xexk8kx3 (v = vs.80).aspx [ http://connectionstrings.com/ [ ^ ]
I tried this coding but not working
string sql = "select * from smp_try";
OracleCommand cmd = new OracleCommand(sql, conn);
cmd.CommandType = CommandType.Text;
OracleDataAdapter da = new OracleDataAdapter(cmd)
DataTable dt =new DataTable("smp_try");
da.Fill(dt);
dataGridView1.DataSource = dt;
I think an easier option is to use theDataSet
designer ofVisual Studio
to generate theDataSet
andDataTables
through theAddNewDataSource
wizard. In this regard I think the following articles may be helpful
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/buildingnetapplications/BuildingNETApplications.htm[^]
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/dotnet/getstarted-c/getstarted_c_otn.htm[^]
http://msdn.microsoft.com/en-US/library/xexk8kx3(v=vs.80).aspx[^]
http://connectionstrings.com/[^]
这篇关于如何在C#中将表数据从Oracle.DataAccess.Client加载到datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!