Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: DataGrid Turning Off Row Headers Pin
sreejith ss nair27-Sep-04 21:03
sreejith ss nair27-Sep-04 21:03 
GeneralRE: Passing Dataset Pin
pj_twitch27-Sep-04 10:07
pj_twitch27-Sep-04 10:07 
GeneralRe: RE: Passing Dataset Pin
sreejith ss nair27-Sep-04 21:08
sreejith ss nair27-Sep-04 21:08 
GeneralRE: Passing Dataset Pin
pj_twitch27-Sep-04 10:05
pj_twitch27-Sep-04 10:05 
GeneralPasting Copied Files into C# .NET App Pin
McClamm27-Sep-04 9:36
McClamm27-Sep-04 9:36 
GeneralRe: Pasting Copied Files into C# .NET App Pin
McClamm27-Sep-04 11:40
McClamm27-Sep-04 11:40 
GeneralForm Transparency Issues Pin
othell27-Sep-04 9:29
othell27-Sep-04 9:29 
QuestionDatagrid Secrets?????????? Pin
Neko0327-Sep-04 9:01
Neko0327-Sep-04 9:01 
I found this code somewhere and changed it for use in my project. It doesn't work and I can't find anywhere or anyobe who can tell me how to work with a datagrid.

Is it a big secret? Is no one allowed to know how to work with this bloody thing?

This is the code:
partial class frmWords : MNLForm
{
OleDbConnection myConn;
OleDbDataAdapter myAdapter;
DataSet ds;
OleDbParameter workParam = null;
string myQuery = "select ID, Word from Thai";

public frmWords()
{
InitializeComponent();
ConnectToData(); // establish database connection and create DataSet
grdThaiWords.DataSource = ds.Tables[0].DefaultView;
//myGrid.SetDataBinding(ds, "CardTest");
DataTable t = ds.Tables[0];
t.RowChanged += new DataRowChangeEventHandler(Row_Changed);
}

private void Words_Load(object sender, EventArgs e)
{

}

public void ConnectToData()
{
ds = new DataSet();
myConn = new OleDbConnection(System.Configuration.ConfigurationSettings.ConnectionStrings["Dictionary"].ConnectionString);
myAdapter = new OleDbDataAdapter();
myAdapter.SelectCommand = new OleDbCommand(myQuery, myConn);
myAdapter.Fill(ds, "Thai");
insertCommand();
updateCommand();
}

public void updateCommand()
{
string updateQuery = "Update Thai Set Word = @Word WHERE ID = @ID";
myAdapter.UpdateCommand = new OleDbCommand(updateQuery, myConn);

workParam = myAdapter.UpdateCommand.Parameters.Add("@Word", OleDbType.Char);
workParam.SourceColumn = "Word";
workParam.SourceVersion = DataRowVersion.Current;
}

private void Row_Changed(object ob, DataRowChangeEventArgs e)
{
DataTable t = (DataTable)ob;
Console.WriteLine("RowChanged " + e.Action.ToString() + "\t" + e.Row.ItemArray[0]);
}

public void insertCommand()
{
string insertQuery = "Insert into Thai VALUES (@Word)";
myAdapter.InsertCommand = new OleDbCommand(insertQuery, myConn);

workParam = myAdapter.InsertCommand.Parameters.Add("@Word", OleDbType.Char);
workParam.SourceColumn = "Word";
workParam.SourceVersion = DataRowVersion.Current;
}


public void UpdateValue()
{
try
{
myAdapter.Update(ds, "CardTest");
Console.Write("Updating DataSet succeeded!");
}
catch (Exception e)
{
Console.Write(e.ToString());
}
}

}
I just want a datagrid that does a update when something is changed and inserts when there is a new row.

Thanks
Cry | :((
AnswerRe: Datagrid Secrets?????????? Pin
MarkMokris27-Sep-04 10:07
MarkMokris27-Sep-04 10:07 
GeneralRe: Datagrid Secrets?????????? Pin
Judah Gabriel Himango27-Sep-04 10:17
sponsorJudah Gabriel Himango27-Sep-04 10:17 
QuestionHow can I get the Physical IP on client server App ??? Pin
Ahmed Mihaimeed27-Sep-04 7:41
Ahmed Mihaimeed27-Sep-04 7:41 
Questionhow to create outlook 2003 type colors? Pin
vista2727-Sep-04 7:18
vista2727-Sep-04 7:18 
AnswerRe: how to create outlook 2003 type colors? Pin
McClamm27-Sep-04 10:07
McClamm27-Sep-04 10:07 
GeneralRe: how to create outlook 2003 type colors? Pin
vista2727-Sep-04 10:41
vista2727-Sep-04 10:41 
GeneralRe: how to create outlook 2003 type colors? Pin
McClamm27-Sep-04 11:02
McClamm27-Sep-04 11:02 
QuestionHow to configure visual studio for debugging in https(ssl) mode a WebApplication in c#? Pin
zoltix27-Sep-04 5:02
zoltix27-Sep-04 5:02 
GeneralGetting Rid of Asterisk Row in DataGrid Pin
MarkMokris27-Sep-04 2:00
MarkMokris27-Sep-04 2:00 
GeneralRe: Getting Rid of Asterisk Row in DataGrid Pin
RoyClem27-Sep-04 2:36
RoyClem27-Sep-04 2:36 
GeneralRe: Getting Rid of Asterisk Row in DataGrid Pin
MarkMokris27-Sep-04 2:54
MarkMokris27-Sep-04 2:54 
GeneralRe: Getting Rid of Asterisk Row in DataGrid Pin
MarkMokris27-Sep-04 3:45
MarkMokris27-Sep-04 3:45 
GeneralRe: Getting Rid of Asterisk Row in DataGrid Pin
the last free name27-Sep-04 6:00
the last free name27-Sep-04 6:00 
GeneralRe: Getting Rid of Asterisk Row in DataGrid Pin
MarkMokris27-Sep-04 7:18
MarkMokris27-Sep-04 7:18 
GeneralMAPI in C# Pin
Ashutosh j27-Sep-04 1:09
Ashutosh j27-Sep-04 1:09 
GeneralRe: MAPI in C# Pin
sreejith ss nair27-Sep-04 3:01
sreejith ss nair27-Sep-04 3:01 
GeneralRe: MAPI in C# Pin
Ashutosh j27-Sep-04 3:17
Ashutosh j27-Sep-04 3:17 

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.