Click here to Skip to main content
12,510,836 members (52,078 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: .NET Oracle ODP.NET
Something wrong is happening, when I'm trying to get the name of the table, which is currently shown in DataGridView. To get the table from Oracle, I use this code:
DataSet ds = new DataSet();
OracleDataAdapter ndadptr = new OracleDataAdapter("SELECT * FROM"+               listBox1.SelectedItem.ToString(), OrConn.conn);
ndadptr.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
But when I'm trying to get current table name with
dataGridView1.DataMember
it returns an empty string. For now, I've created class member Current_Table_Name, and write the selected item from listbox into it. Is there any other solution and how can I get the table name via DataMember property?
Posted 2-Feb-13 4:49am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

this way
DataSet ds = new DataSet();
OracleDataAdapter ndadptr = new OracleDataAdapter("SELECT * FROM "+               listBox1.SelectedItem.ToString(), OrConn.conn);
ndadptr.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.DataMember = ds.Tables[0].Name;

then you will able to retrieve datamember
Happy Coding!
:)
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

The answer at http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/592687b6-da67-4362-86c0-16c7e95de452/[^] explains why this is happening and also gives a workaround.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160929.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100