Click here to Skip to main content
15,922,533 members
Home / Discussions / C#
   

C#

 
AnswerRe: Convert code C# 2008 to code C# 2005 ? Pin
OriginalGriff24-Feb-15 22:05
mveOriginalGriff24-Feb-15 22:05 
GeneralRe: Convert code C# 2008 to code C# 2005 ? Pin
Member 245846725-Feb-15 16:22
Member 245846725-Feb-15 16:22 
GeneralRe: Convert code C# 2008 to code C# 2005 ? Pin
OriginalGriff25-Feb-15 21:51
mveOriginalGriff25-Feb-15 21:51 
GeneralRe: Convert code C# 2008 to code C# 2005 ? Pin
Member 24584673-Mar-15 15:42
Member 24584673-Mar-15 15:42 
QuestionInsert the data of datagridview in a database. Pin
Ibrahim.elh24-Feb-15 20:45
Ibrahim.elh24-Feb-15 20:45 
QuestionRe: Insert the data of datagridview in a database. Pin
Eddy Vluggen25-Feb-15 0:31
professionalEddy Vluggen25-Feb-15 0:31 
AnswerRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 1:55
Ibrahim.elh25-Feb-15 1:55 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 2:09
mveRichard Deeming25-Feb-15 2:09 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 2:58
Ibrahim.elh25-Feb-15 2:58 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 3:02
mveRichard Deeming25-Feb-15 3:02 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 3:06
Ibrahim.elh25-Feb-15 3:06 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 3:10
mveRichard Deeming25-Feb-15 3:10 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 3:12
Ibrahim.elh25-Feb-15 3:12 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 3:14
mveRichard Deeming25-Feb-15 3:14 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 3:39
Ibrahim.elh25-Feb-15 3:39 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 3:49
mveRichard Deeming25-Feb-15 3:49 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 3:59
Ibrahim.elh25-Feb-15 3:59 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 4:08
mveRichard Deeming25-Feb-15 4:08 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 4:11
Ibrahim.elh25-Feb-15 4:11 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 4:25
mveRichard Deeming25-Feb-15 4:25 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 4:31
Ibrahim.elh25-Feb-15 4:31 
GeneralRe: Insert the data of datagridview in a database. Pin
Richard Deeming25-Feb-15 4:41
mveRichard Deeming25-Feb-15 4:41 
GeneralRe: Insert the data of datagridview in a database. Pin
Ibrahim.elh25-Feb-15 4:47
Ibrahim.elh25-Feb-15 4:47 
GeneralRe: Insert the data of datagridview in a database(error). Pin
Ibrahim.elh25-Feb-15 4:48
Ibrahim.elh25-Feb-15 4:48 
GeneralRe: Insert the data of datagridview in a database(error). Pin
Richard Deeming25-Feb-15 4:54
mveRichard Deeming25-Feb-15 4:54 
Your code should look like this:
C#
using (OdbcConnection connection = new OdbcConnection(lc.Connexion_locale))
using (OdbcCommand command = new OdbcCommand("insert into thisdet2 (cat,geo,etb,nobl,vend,fam,art,des,tare) values (?,?,?,?,?,?,?,?,?)", connection))
{
    // ODBC doesn't use named parameters, so the names don't matter:

    OdbcParameter cat = command.Parameters.Add("@cat", OdbcType.NVarChar);
    OdbcParameter geo = command.Parameters.Add("@geo", OdbcType.NVarChar);
    OdbcParameter etb = command.Parameters.Add("@etb", OdbcType.NVarChar);
    OdbcParameter nobl = command.Parameters.Add("@nobl", OdbcType.NVarChar);
    OdbcParameter vend = command.Parameters.Add("@vend", OdbcType.NVarChar);
    OdbcParameter fam = command.Parameters.Add("@fam", OdbcType.NVarChar);
    OdbcParameter art = command.Parameters.Add("@art", OdbcType.NVarChar);
    OdbcParameter des = command.Parameters.Add("@des", OdbcType.NVarChar);
    OdbcParameter tare = command.Parameters.Add("@tare", OdbcType.NVarChar);
    
    connection.Open();
    
    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
    {
        DataGridViewRow row = dataGridView1.Rows[i];
        
        cat.Value = row.Cells[0].Value;
        geo.Value = row.Cells[1].Value;
        etb.Value = row.Cells[2].Value;
        nobl.Value = row.Cells[3].Value;
        vend.Value = row.Cells[4].Value;
        fam.Value = row.Cells[5].Value;
        art.Value = row.Cells[6].Value;
        des.Value = row.Cells[7].Value;
        tare.Value = row.Cells[8].Value;
        
        command.ExecuteNonQuery();
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


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.