topical media & game development
basic-mysql-19-ASPApp-insert.aspx / aspx
<%
*****************************************************************************
Author: Geoff Moes and Robert Sheldon
Project: Begining MySQL - Chapter 19
Module: insert.aspx
Date: 12/10/04
Description:
Include file that contains the logic for the insert functionality.
*****************************************************************************
%>
<%
// Build the INSERT statement with parameter references
String insertSql = "INSERT INTO Transactions (OrderID, DVDID, DateOut, DateDue) VALUES (?, ?, ?, ?)";
odbcCommand = new OdbcCommand(insertSql, odbcConnection);
OdbcParameter [] odbcInsertParameters = new OdbcParameter[4];
// Set the parameters
odbcInsertParameters[0] = new OdbcParameter("", OdbcType.Int);
odbcInsertParameters[0].Value = orderId;
odbcInsertParameters[1] = new OdbcParameter("", OdbcType.Int);
odbcInsertParameters[1].Value = dvdId;
odbcInsertParameters[2] = new OdbcParameter("", OdbcType.Date);
odbcInsertParameters[2].Value = dateOut;
odbcInsertParameters[3] = new OdbcParameter("", OdbcType.Date);
odbcInsertParameters[3].Value = dateDue;
odbcCommand.Parameters.Add(odbcInsertParameters[0]);
odbcCommand.Parameters.Add(odbcInsertParameters[1]);
odbcCommand.Parameters.Add(odbcInsertParameters[2]);
odbcCommand.Parameters.Add(odbcInsertParameters[3]);
// Execute the INSERT statement
odbcCommand.ExecuteNonQuery();
if(odbcCommand != null)
odbcCommand.Dispose();
if(odbcConnection != null)
odbcConnection.Dispose();
%>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.