Click here to Skip to main content
15,924,317 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to merge and split cells in datagridview? Pin
dan!sh 30-Nov-09 21:27
professional dan!sh 30-Nov-09 21:27 
GeneralRe: How to merge and split cells in datagridview? Pin
Søren Fog31-Aug-10 3:02
Søren Fog31-Aug-10 3:02 
GeneralRe: How to merge and split cells in datagridview? Pin
Abhinav S18-Oct-10 18:25
Abhinav S18-Oct-10 18:25 
QuestionError in save file ... Pin
mostafa_h30-Nov-09 19:01
mostafa_h30-Nov-09 19:01 
AnswerRe: Error in save file ... Pin
souidi abderrahman30-Nov-09 21:01
souidi abderrahman30-Nov-09 21:01 
GeneralRe: Error in save file ... Pin
mostafa_h30-Nov-09 21:17
mostafa_h30-Nov-09 21:17 
AnswerRe: Error in save file ... Pin
CikaPero1-Dec-09 22:42
CikaPero1-Dec-09 22:42 
Questionfilling a dataGridView, editing and overwriting [modified] Pin
Emmet_Brown30-Nov-09 18:22
Emmet_Brown30-Nov-09 18:22 
Hello everyone

I've once asked this question but I thought that I couldn't make it clear.

I have a table and I want to view it on my dataGridView.
I need to fill this dataGridView by codes, not with the interface.


I also allowed the user to edit this dataGridView in the runtime. User can change the values of cells, and also add rows to the table.

My two questions are:

how can I fill this dataGridView by hardcoding
and how can I overwrite the loaded table with the edited table by the user?



please please please help and be clear with me in this. I'm pretty rookie and this is the only thing left in my project to finish Frown | :(


EDIT!
Somehow I managed to fill the table, now, only saving left. Please. Anyone?

EDIT2

well, I did sth Smile | :)

I'm filling the table like this:

string strCon = "Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "Veritabani.sdf; Persist Security Info=False";
            SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM Kasa", strCon);
            SqlCeCommandBuilder cb = new SqlCeCommandBuilder(da);
            DataSet ds = new DataSet();
            da.Fill(ds);
            dbGridView.DataSource = ds.Tables[0];


it works,

and from the same source, someone says that "you can use 'da.Update(ds);' for updating your table"

I want to update the table on some SAVE button, so I wrote this:

private void saveButton_Click(object sender, EventArgs e)
        {
            string strCon = "Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "Veritabani.sdf; Persist Security Info=False";
            SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM Kasa", strCon);
            SqlCeCommandBuilder cb = new SqlCeCommandBuilder(da);
            DataSet ds = new DataSet();
            da.Fill(ds);
            da.Update(ds);
            this.Close();
            
        }


bu "da.Update(ds)" does not update my table in the database

where is my mistake?

modified on Tuesday, December 1, 2009 1:06 AM

AnswerRe: filling a dataGridView, editing and overwriting Pin
dan!sh 30-Nov-09 19:20
professional dan!sh 30-Nov-09 19:20 
GeneralRe: filling a dataGridView, editing and overwriting Pin
Emmet_Brown30-Nov-09 19:35
Emmet_Brown30-Nov-09 19:35 
GeneralRe: filling a dataGridView, editing and overwriting Pin
dan!sh 30-Nov-09 21:20
professional dan!sh 30-Nov-09 21:20 
GeneralRe: filling a dataGridView, editing and overwriting Pin
Emmet_Brown30-Nov-09 21:29
Emmet_Brown30-Nov-09 21:29 
AnswerRe: filling a dataGridView, editing and overwriting Pin
souidi abderrahman30-Nov-09 20:59
souidi abderrahman30-Nov-09 20:59 
GeneralRe: filling a dataGridView, editing and overwriting Pin
Emmet_Brown30-Nov-09 21:08
Emmet_Brown30-Nov-09 21:08 
AnswerRe: filling a dataGridView, editing and overwriting Pin
souidi abderrahman30-Nov-09 21:37
souidi abderrahman30-Nov-09 21:37 
GeneralRe: filling a dataGridView, editing and overwriting Pin
Emmet_Brown30-Nov-09 21:42
Emmet_Brown30-Nov-09 21:42 
QuestionCreate playlist and play using windows media player control Pin
yesu prakash30-Nov-09 18:03
yesu prakash30-Nov-09 18:03 
AnswerRe: Create playlist and play using windows media player control Pin
dan!sh 30-Nov-09 19:29
professional dan!sh 30-Nov-09 19:29 
QuestionObject array problem Pin
CrazyCoder2630-Nov-09 17:53
CrazyCoder2630-Nov-09 17:53 
AnswerRe: Object array problem Pin
dan!sh 30-Nov-09 18:25
professional dan!sh 30-Nov-09 18:25 
GeneralRe: Object array problem Pin
CrazyCoder2630-Nov-09 18:29
CrazyCoder2630-Nov-09 18:29 
GeneralRe: Object array problem Pin
dan!sh 30-Nov-09 18:43
professional dan!sh 30-Nov-09 18:43 
AnswerRe: Object array problem Pin
Blue_Boy30-Nov-09 20:55
Blue_Boy30-Nov-09 20:55 
GeneralRe: Object array problem Pin
vtchris-peterson1-Dec-09 7:20
vtchris-peterson1-Dec-09 7:20 
GeneralRe: Object array problem Pin
CikaPero2-Dec-09 5:05
CikaPero2-Dec-09 5:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.