本文介绍了无法在windows应用程序帮助中从oracle数据库向gridview显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 #region course selected index private void CB_Course_SelectedIndexChanged(object sender, EventArgs e) { coursewisereport(); } #endregion #region grid coursewisereport private void coursewisereport() { try { objdatabaseclass = new DataBaseClass(); objstudentlistclass = new property_function_class.StudentListClass(); objstudentlistclass.COURS = CB_Course.Text.Trim(); dataset = objstudentlistclass.Getcoursewisereport(); dbBindSource.DataSource = dataset; DbGrid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); DbGrid.DataSource = dbBindSource; } catch { MessageBox.Show("selected data not in db"); } } #endregion studentlistclass.cs ---------------------------- studentlistclass.cs----------------------------#region getcoursewisereport function public DataSet Getcoursewisereport() { DataBaseClass objdatabaseclass = new DataBaseClass(); dataset = new DataSet(); dataset = objdatabaseclass.GetDataset(string.Format("select studentid,name,nameofgud,location,mobile from registration where course='" + course + "'")); return dataset; } #endregion -------------------- databaseclass.cs --------------- --------------------databaseclass.cs---------------public DataSet GetDataset(string ProcedureName) { try { Objcommand = new OracleCommand(ProcedureName, Objconnection); Objcommand.CommandType = CommandType.Text; // Handle the parameters Objadapter = new OracleDataAdapter(Objcommand); objcommandbuilder = new OracleCommandBuilder(Objadapter); Objdataset = new DataSet(); Objdataset.Locale = System.Globalization.CultureInfo.InvariantCulture; Objadapter.Fill(Objdataset); } catch (Exception Objerrormessage) { throw Objerrormessage; } finally { //release all resource of connection object Objconnection.Dispose(); } return Objdataset; } 推荐答案 那么 GetDataset中的 Objconnection 怎么样? 方法是打开的,活动的well what about the Objconnection in GetDataset method is it open, and active 这篇关于无法在windows应用程序帮助中从oracle数据库向gridview显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 03:45