vs2005/C#/MS Access: Insert doesn't add row to db


hey all:

i wrote c# program sent arduino parameter. 1 received, arduino sends data tempature sensor pc. program takes info , tries load database.

the program passes info arduino , received info in return. however, insert sql statement not load data database though there no errors insert statement.

am leaving out? maybe statement commit or something? appreciated.

here's code:

private void button1_click(object sender, eventargs e)
       {
           //========================================================================
           // when button clicked, program sends parm serial port.
           // external device connected serial port sends information
           // serial port. program takes information , places
           // in textboxes , tries add data (along hard coded data)
           // database using insert sql statement.
           //========================================================================

           //====  creates/opens/reads/closes serial port.
           serialport activeserial = new serialport("com4", 9600,
           parity.none, 8, stopbits.one);
           activeserial.readbuffersize = 128;
           activeserial.open();
           //=========sends parm serial port (external device)
           activeserial.write("t");
           //=============programs data serial port
           string datafromarduino = activeserial.readline();
           activeserial.close();

           //======the data placed in varialbles.

           int sqlid = 8;
           datetime sqltoday = datetime.now;
           string sqltype = "'temp'";
           int sqltemp = convert.toint16(datafromarduino);
           string sqlname = "'lm35dz'";
           string sqllocation = "'attic'";

           textbox6.text = convert.tostring(sqlid);
           textbox1.text = convert.tostring(sqltoday);
           textbox2.text = sqltype;
           textbox3.text = convert.tostring(sqltemp);
           textbox4.text = sqlname;
           textbox5.text = sqllocation;

           //========creation of database connection string ms access
           system.data.oledb.oledbconnection conn = new system.data.oledb.oledbconnection();
           conn.connectionstring = @"provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\templog.mdb";


           try
           {
               string insertsql = "insert temp (id, stype, faherenheit, partnum, placement)" +
                                  " values (" + sqlid + "," + sqltype + "," + sqltemp + "," + sqlname + "," + sqllocation + ")";
               //messagebox.show(insertsql);
               oledbcommand command = new oledbcommand(insertsql);
               command.connection = conn;
               conn.open();         //=== opens db connection
               command.executenonquery();  //=== executes 'insert into' sql            }
           catch (exception caught)
           {
               messagebox.show(caught.message);
           }
           finally
           {
               conn.close();
           }
       }

is code on arduino working correctly?

did ask on microsoft forum how program arduino?


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > vs2005/C#/MS Access: Insert doesn't add row to db


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums