4 Replies - 9186 Views - Last Post: 08 September 2011 - 12:18 PM Rate Topic: -----

#1 thenndral  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-August 11

DataGridView - Show/Insert/Update/Delete

Posted 06 September 2011 - 08:56 PM

Hi all,

I'm new to C# and our forum.

I just start code in C#.
I'm using visual studio 2008 and oracle database9i.
I need a code data manipulation with oracle db. ie. I want to access the oracle table through datagridview[showdata/insert/update/delete].

1. How to Bind the data to datagridview using dataset.
2. How to insert/update/delete using dataset in a datagridview.

Can you give me the samples to start.

Thanks in advance,
thenndral

Is This A Good Question/Topic? 0
  • +

Replies To: DataGridView - Show/Insert/Update/Delete

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4188
  • View blog
  • Posts: 11,857
  • Joined: 18-April 07

Re: DataGridView - Show/Insert/Update/Delete

Posted 06 September 2011 - 09:30 PM

Some code to chew on...

OleDbConnection OracleConnection = new OleDbConnection(sourceString); 

// Create a DataAdapter 
OleDbDataAdapter OracleDataAdapter = new OleDbDataAdapter(selectString, OracleConnection); 
 
// Create the DataSet 
DataSet OracleDataSet = new DataSet(); 

// Fill the dataset and give it a table name 
OracleDataAdapter.Fill(OracleDataSet, "example_table"); 

// Now set the data source using that table name
dataGrid.DataSource = OracleDataSet.Tables["example_table"];



In the code above the source string will be your connection string information and selectString would be your select statement.

Enjoy! :)
Was This Post Helpful? 0
  • +
  • -

#3 KFredje  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 131
  • Joined: 06-September 11

Re: DataGridView - Show/Insert/Update/Delete

Posted 07 September 2011 - 05:58 AM

Have a look here: http://www.dreaminco...iew-using-c%23/
Was This Post Helpful? 0
  • +
  • -

#4 thenndral  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-August 11

Re: DataGridView - Show/Insert/Update/Delete

Posted 07 September 2011 - 09:56 PM

Thank you for your reply.

Its Help me to good start...

Here I attach my code, have a look and give your guidance.

1. after save data how to refresh datagridview.
2. how to update / delete from datagridview and at the same time it should be affect the table too...

After i finish this work, i want to start study.... 1 dataset into 2 or 3 tables...

thanks for all helps...
thenndral

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#5 KFredje  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 131
  • Joined: 06-September 11

Re: DataGridView - Show/Insert/Update/Delete

Posted 08 September 2011 - 12:18 PM

To refresh my datagridview I first use (td is my DataTable)
dt.Clear();

and then I load my data again in it.

For your second question I can't help. I have trouble using a database myself, so I solved this with a .xls file with all my data in it, just like a database. Updating and Deleting a row in my database always failed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1