[C#]need help to write in database the datagridview rows text

[C#]
Here is my problem Tongue Tied

Cant understand how insert in my database the value of which i write in datagridview rows.

Any help really appreciated.


Answer this question

[C#]need help to write in database the datagridview rows text

  • jasms

    Hi, and thx for reply ;)

    Im still having trouble.

    I try in the follow way:

    myAdapter = new MySqlDataAdapter();
    myAdapter.InsertCommand = new MySqlCommand(myQuery, myCon);
    myData = new DataSet();
    myAdapter.Fill(myData, "myTable");

    myGrid.DataSource = myData;
    myGrid.DataMember = "myTable"

    myParam = new MySqlParameter();
    myParam = myAdapter.InsertCommand.Parameters.Add("@myVariable", MySqlDbType.VarChar);

    myParam.SourceColumn = "myColumn";
    myParam.SourceVersion = DataRowVersion.Current;
    myAdapter.Update(myData, "myTable");

    in this case, my insert query is;

    string myQuery = "INSERT INTO myTable (myColumn) VALUES(@myColumn)";

    so.....after all...still doesnt work :(


  • jefseyen

    Hi,

    When you create a new row or modify a row the changes it inflicts are reflected to its underlying source (a datatable or dataset). So to send the changes or get the changes you could see the underlying source. To send updates to the database you could use a DataAdapter.Update command...

     

     

    cheers,

    Paul June A. Domag



  • vidya narayanan

    well :) just solved this problem too....

    Only needed to assign a column index at "@MyColumn" and it worked.



  • Brak59


    string myQuery = "INSERT INTO myTable (myColumn) VALUES(@myColumn)";


    so....which is the value of "@myColumn"



  • [C#]need help to write in database the datagridview rows text