Tagom
asked on
form not passing data
I have missed something with these two pages.
The front end loads and gives no error - the submit button does not give results
The data is not transferred to the table. - I do not usually code in asp, doing this as a favor so any help is gratefully appreciated.
Front End
The front end loads and gives no error - the submit button does not give results
The data is not transferred to the table. - I do not usually code in asp, doing this as a favor so any help is gratefully appreciated.
Front End
<%@ Page Language="c#" AutoEventWireup="false" CodeBehind="rainEvents.aspx.cs" Inherits="FileUpload.WebForm1"
Src="rainEvents.aspx.cs" %>
<html>
<head>
</head>
<body ms_positioning="GridLayout">
<br />
<form id="Form1" method="post" runat="server" enctype="multipart/form-data"><br />
Enter the Collection Date: <asp:TextBox ID="collection" runat="server" />
<br /> <br />
Enter the Site Code: (M,E,P or B)<asp:TextBox ID="site" runat="server" /><br /> <br />
Enter the Bottle Number: <asp:TextBox ID="bottleNumber" runat="server" /><br /> <br />
Enter the Bottle_type: (T or P) <asp:TextBox ID="bottleType" runat="server" /><br /> <br />
Enter the Bottle Rep (A or B): <asp:TextBox ID="bottleRep" runat="server" /><br /> <br />
Enter the Date Deployed: <asp:TextBox ID="deployed" runat="server" /><br /> <br />
Enter the Collection Time: <asp:TextBox ID="collectionTime" runat="server" /><br /> <br />
Enter the UWF User ID: <asp:TextBox ID="userId" runat="server" /><br /> <br />
Enter the tareWGT: <asp:TextBox ID="tareWgt" runat="server" /><br /> <br />
Enter the totalWGT: <asp:TextBox ID="TotalWgt" runat="server" /><br /> <br />
Enter the Sample WGT: <asp:TextBox ID="sampleWgt" runat="server" /><br /> <br />
Enter the Ph: <asp:TextBox ID="pH" runat="server" /><br /> <br />
Enter the Notes: <asp:TextBox ID="Notes" runat="server" /><br /> <br />
Is the sample Contaminated? <asp:CheckBox ID="contaminated" runat="server" /><br /> <br />
<br />
<asp:Button ID="cmdSend" runat="server" Text="Send" />
<br />
<br />
</form>
</body>
</html>
Back Endusing System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Data;
using System.Data.OleDb;
namespace FileUpload
{
public class WebForm1 : System.Web.UI.Page
{
private const string MDBFILE = "~/hgdeposition/App_Data/hgweb.mdb";
protected Label lblFile;
protected HtmlInputFile filMyFile;
//protected System.Web.UI.WebControls.Label lblInfo;
protected System.Web.UI.WebControls.TextBox collection;
protected System.Web.UI.WebControls.TextBox site;
protected System.Web.UI.WebControls.TextBox bottleNumber;
protected System.Web.UI.WebControls.TextBox bottleType;
protected System.Web.UI.WebControls.TextBox bottleRep;
protected System.Web.UI.WebControls.TextBox deployed;
protected System.Web.UI.WebControls.TextBox collectionTime;
protected System.Web.UI.WebControls.TextBox userId;
protected System.Web.UI.WebControls.TextBox tareWgt;
protected System.Web.UI.WebControls.TextBox TotalWgt;
protected System.Web.UI.WebControls.TextBox sampleWgt;
protected System.Web.UI.WebControls.TextBox pH;
protected System.Web.UI.WebControls.TextBox Notes;
protected System.Web.UI.WebControls.CheckBox contaminated;
protected System.Web.UI.WebControls.Button cmdSend;
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.cmdSend.Click += new System.EventHandler(this.cmdSend_Click);
}
private void Page_Load(object sender, System.EventArgs e)
{
}
// Processes click on our cmdSend button
private void cmdSend_Click(object sender, System.EventArgs e)
{
}
// Generates database connection string
private string GetConnectionString()
{
return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(MDBFILE) + ";";
}
// Writes file to the database
private int WriteToDB(DateTime collection, string site, string bottle_number, string bottlerep, DateTime deploy, DateTime myDateTime, string UserId_uwf, int tareWGT, int totalWGT, int sample_ml, int ph, string Notes, bool contaminated)
{
int nFileID = 0;
// Create connection
OleDbConnection dbConn = new OleDbConnection(GetConnectionString());
// Create Adapter
OleDbDataAdapter dbAdapt = new OleDbDataAdapter("SELECT * FROM rainEventsTest", dbConn);
// We need this to get an ID back from the database
dbAdapt.MissingSchemaAction = MissingSchemaAction.AddWithKey;
// Create and initialize CommandBuilder
OleDbCommandBuilder dbCB = new OleDbCommandBuilder(dbAdapt);
// Open Connection
dbConn.Open();
// New DataSet
DataSet dbSet = new DataSet();
// Populate DataSet with data
dbAdapt.Fill(dbSet, "rainEventsTest");
// Get reference to our table
DataTable dbTable = dbSet.Tables["rainEventsTest"];
// Create new row
DataRow dbRow = dbTable.NewRow();
// Store data in the row
//dbRow["pKey"] = AutoNumber;
dbRow["collection_date"] = collection.Date.ToShortDateString();
dbRow["Site"] = site;
dbRow["bottle_number"] = bottle_number;
dbRow["bottlerep"] = bottlerep;
dbRow["date_deployed"] = deploy.Date.ToShortDateString();
dbRow["Collection_time"] = myDateTime.ToString("t");
dbRow["UserId_uwf"] = UserId_uwf;
dbRow["tareWGT"] = tareWGT;
dbRow["totalWGT"] = totalWGT;
dbRow["sample_ml"] = sample_ml;
dbRow["ph"] = ph;
dbRow["Notes"] = Notes;
dbRow["contaminated"] = contaminated;
// Add row back to table
dbTable.Rows.Add(dbRow);
// Update data source
dbAdapt.Update(dbSet, "rainEventsTest");
// Get newFileID
if (!dbRow.IsNull("FileID"))
nFileID = (int)dbRow["Pkey"];
// Close connection
dbConn.Close();
// Return FileID
return nFileID;
}
}
}
There is no code in the cmdSend button click event
ASKER
Do you have an example of what should go there by chance.
I have a long extensive example but it is difficult for me to follow.
I have a long extensive example but it is difficult for me to follow.
What do you want to do when the button is clicked?
private void cmdSend_Click(object sender, System.EventArgs e)
{
' you need to do what ever you want here
}
private void cmdSend_Click(object sender, System.EventArgs e)
{
' you need to do what ever you want here
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.