tearing my hair out

M

Mickey

I've got some very simple code inserting data into a database. I have been
through it and through it probably a hundred times today. There is one
field that is not being updated in the database. I am as sure as I can get
that the code is correct. The same code is being used elsewhere and works
fine.

The txtWorksTitle is not being inserted into the "title" field, although the
txtFundingTitle is being inserted into the database and it uses the exact
same code and database field. See WORKS and FUNDING blocks below. All other
fields are fine. The database field is correct and the form field is
correct.


****************WORKS*******************
from the form page:

<asp:TextBox ID="txtWorksTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>
<asp:Button ID="btnWorksSaveOpportunity" runat="server"
OnClick="btnWorksUpdateOpportunity_Click"
Text="Save Opportunity" Width="110px" />


..cs page:

protected void btnWorksUpdateOpportunity_Click(object sender, EventArgs e)
{
if (txtWorksDescription.Value.Trim() != "")
{
Works_HarvestAndUpdateValues();
message3.Visible = true;
Label71.Visible = false;
}
else
{
Label71.Visible = true;
}
}
private void Works_HarvestAndUpdateValues()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtWorksTitle.Text;
myRow["type"] = cboWorksType.SelectedValue.ToString();
myRow["deadline"] = txtWorksDeadline.Text;
myRow["contact"] = txtWorksContact.Text;
myRow["description"] = txtWorksDescription.Value;
myRow["moreInformation"] = txtWorksMoreInformation.Value;
myRow["displayOpportunity"] = cbxActive.Checked;



_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());


}

**************** END WORKS*******************

*****************FUNDING*********************

AND YET the following works fine using the same table for the title field:

form page:

<asp:TextBox ID="txtFundingTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>

..cs page:

protected void btnFundingUpdateOpportunity_Click(object sender, EventArgs e)
{
if (txtFundingDescription.Value.Trim() != "")
{
harvestAndUpdateFundingFields();
message.Visible = true;
Label74.Visible = false;
}
else
{
Label74.Visible = true;
}
}
private void harvestAndUpdateFundingFields()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtFundingTitle.Text;
myRow["fundingSource"] = txtFundingSource.Text;
myRow["fundingType"] = txtFundingType.Text;
myRow["amount"] = txtFundingAmount.Text;
myRow["numAwardsAvailable"] =
int.Parse(txtFundingNumAwardsAvailable.Text);
myRow["awardCeiling"] = txtFundingCeiling.Text;
myRow["awardFloor"] = txtFundingFloor.Text;
myRow["eligibility"] = txtFundingElgibility.Value;
myRow["deadline"] = txtFundingDeadline.Text;
myRow["description"] = txtFundingDescription.Value;
myRow["moreInformation"] = txtFundingMoreInfo.Value;
myRow["displayOpportunity"] = cbxActive.Checked;

_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());

}

************END FUNDING*********************

public void UpdateOppoutunity(DataSet updatedDs, string userID)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "UpdateOpportunity";
DbCommand UpdateCommand = db.GetStoredProcCommand(sqlCommand);

string modifiedDate = DateTime.Now.ToString();

string
username, dateAdded,
title, dateModified, modifiedBy,
fundingSource, fundingType, eligibility,
deadline, description, moreInformation,
position, jobType, company,
department, address, city,
state, zip, zip4, type,
contact, events, location,
topic, date, organization,
qualifications, compensation, edutactionType,
source, categories, nominationForm,
salaryLevel, amount, awardCeiling,
awardFloor, country;

bool displayOpportunity;

int
iD, opportunity_ID, numAwardsAvailable;

DataRow myRow = updatedDs.Tables[0].Rows[0];


string sNumAwards = "0";
if (myRow["numAwardsAvailable"].ToString() != string.Empty )
sNumAwards = myRow["numAwardsAvailable"].ToString();


iD = int.Parse (myRow["ID"].ToString());
opportunity_ID = int.Parse (myRow["Opportunity_ID"].ToString());
username = userID;
displayOpportunity =
Convert.ToBoolean(myRow["displayOpportunity"].ToString());
dateAdded = myRow["dateAdded"].ToString();
title = myRow["title"].ToString();
dateModified = modifiedDate;
modifiedBy = username;
fundingSource = myRow["fundingSource"].ToString();
fundingType = myRow["fundingType"].ToString();
try{
amount =
(Convert.ToDouble(myRow["amount"].ToString())).ToString();
}catch(Exception e){
amount = "0";
}
numAwardsAvailable = int.Parse (sNumAwards);
try{
awardCeiling =
(Convert.ToDouble(myRow["awardCeiling"].ToString())).ToString();
}
catch(Exception e){
awardCeiling = "0";
}
try{
awardFloor =
(Convert.ToDouble(myRow["awardFloor"].ToString())).ToString();
}catch(Exception e){
awardFloor = "0";
}
eligibility = myRow["eligibility"].ToString();
deadline = myRow["deadline"].ToString();
description = myRow["description"].ToString();
moreInformation = myRow["moreInformation"].ToString();
position = myRow["position"].ToString();
jobType = myRow["jobType"].ToString();
company = myRow["company"].ToString();
department = myRow["department"].ToString();
address = myRow["address"].ToString();
city = myRow["city"].ToString();
state = myRow["state"].ToString();
country = myRow["countryId"].ToString();
zip = myRow["zip"].ToString();
zip4 = myRow["zip4"].ToString();
type = myRow["type"].ToString();
contact = myRow["contact"].ToString();
events = myRow["event"].ToString();
location = myRow["location"].ToString();
topic = myRow["topic"].ToString();
date = myRow["date"].ToString();
organization = myRow["organization"].ToString();
qualifications = myRow["qualifications"].ToString();
compensation = myRow["compensation"].ToString();
edutactionType = myRow["edutactionType"].ToString();
source = myRow["source"].ToString();
categories = myRow["categories"].ToString();
nominationForm = myRow["nominationForm"].ToString();
salaryLevel = myRow["salaryLevel"].ToString();


db.AddInParameter(UpdateCommand, "ID", DbType.Int32, iD);
db.AddInParameter(UpdateCommand, "Opportunity_ID", DbType.Int32,
opportunity_ID);
db.AddInParameter(UpdateCommand, "userName", DbType.String, username);
db.AddInParameter(UpdateCommand, "displayOpportunity", DbType.Boolean,
displayOpportunity);
db.AddInParameter(UpdateCommand, "dateAdded", DbType.String, dateAdded);
db.AddInParameter(UpdateCommand, "title", DbType.String, title);
db.AddInParameter(UpdateCommand, "dateModified", DbType.String,
dateModified);
db.AddInParameter(UpdateCommand, "modifiedBy", DbType.String,
modifiedBy);
db.AddInParameter(UpdateCommand, "fundingSource", DbType.String,
fundingSource);
db.AddInParameter(UpdateCommand, "fundingType", DbType.String,
fundingType);
db.AddInParameter(UpdateCommand, "amount", DbType.Currency, amount);
db.AddInParameter(UpdateCommand, "numAwardsAvailable", DbType.Int32,
numAwardsAvailable);
db.AddInParameter(UpdateCommand, "awardCeiling",
DbType.Currency, awardCeiling);
db.AddInParameter(UpdateCommand, "awardFloor", DbType.Currency,
awardFloor);
db.AddInParameter(UpdateCommand, "eligibility", DbType.String,
eligibility);
db.AddInParameter(UpdateCommand, "deadline", DbType.String, deadline);
db.AddInParameter(UpdateCommand, "description", DbType.String,
description);
db.AddInParameter(UpdateCommand, "moreInformation", DbType.String,
moreInformation);
db.AddInParameter(UpdateCommand, "position", DbType.String, position);
db.AddInParameter(UpdateCommand, "jobType", DbType.String, jobType);
db.AddInParameter(UpdateCommand, "company", DbType.String, company);
db.AddInParameter(UpdateCommand, "department", DbType.String,
department);
db.AddInParameter(UpdateCommand, "address", DbType.String, address);
db.AddInParameter(UpdateCommand, "city", DbType.String, city);
db.AddInParameter(UpdateCommand, "state", DbType.String, state);
db.AddInParameter(UpdateCommand, "zip", DbType.String, zip);
db.AddInParameter(UpdateCommand, "zip4", DbType.String, zip4);
db.AddInParameter(UpdateCommand, "country", DbType.String, country);

db.AddInParameter(UpdateCommand, "type", DbType.String, type);
db.AddInParameter(UpdateCommand, "contact", DbType.String, contact);
db.AddInParameter(UpdateCommand, "event", DbType.String, events);
db.AddInParameter(UpdateCommand, "location", DbType.String, location);
db.AddInParameter(UpdateCommand, "topic", DbType.String, topic);
db.AddInParameter(UpdateCommand, "date", DbType.String, date);
db.AddInParameter(UpdateCommand, "organization", DbType.String,
organization);
db.AddInParameter(UpdateCommand, "qualifications", DbType.String,
qualifications);
db.AddInParameter(UpdateCommand, "compensation", DbType.String,
compensation);
db.AddInParameter(UpdateCommand, "edutactionType", DbType.String,
edutactionType);
db.AddInParameter(UpdateCommand, "source", DbType.String, source);
db.AddInParameter(UpdateCommand, "categories", DbType.String,
categories);
db.AddInParameter(UpdateCommand, "nominationForm", DbType.String,
nominationForm);
db.AddInParameter(UpdateCommand, "salaryLevel", DbType.String,
salaryLevel);


db.ExecuteNonQuery(UpdateCommand);

}

****************************************

What am I missing? I've been staring at this all day and am ready to tear
my hair out. Could it possibly be something server side? Help! Please!

Thanks,
Mickey
 
H

Hans Kesting

After serious thinking Mickey wrote :
I've got some very simple code inserting data into a database. I have been
through it and through it probably a hundred times today. There is one field
that is not being updated in the database. I am as sure as I can get that
the code is correct. The same code is being used elsewhere and works fine.

The txtWorksTitle is not being inserted into the "title" field, although the
txtFundingTitle is being inserted into the database and it uses the exact
same code and database field. See WORKS and FUNDING blocks below. All other
fields are fine. The database field is correct and the form field is
correct.

What database do you use?
If it is SqlServer, try the Profiler to see if that "title" is sent to
the database.
If not, the problem is in the code here.
If the title *is* sent to the database (as I suspect), the problem is
in your stored procedure (that you didn't show).

Hans Kesting

****************WORKS*******************
from the form page:

<asp:TextBox ID="txtWorksTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>
<asp:Button ID="btnWorksSaveOpportunity" runat="server"
OnClick="btnWorksUpdateOpportunity_Click"
Text="Save Opportunity" Width="110px" />


.cs page:

protected void btnWorksUpdateOpportunity_Click(object sender, EventArgs e)
{
if (txtWorksDescription.Value.Trim() != "")
{
Works_HarvestAndUpdateValues();
message3.Visible = true;
Label71.Visible = false;
}
else
{
Label71.Visible = true;
}
}
private void Works_HarvestAndUpdateValues()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtWorksTitle.Text;
myRow["type"] = cboWorksType.SelectedValue.ToString();
myRow["deadline"] = txtWorksDeadline.Text;
myRow["contact"] = txtWorksContact.Text;
myRow["description"] = txtWorksDescription.Value;
myRow["moreInformation"] = txtWorksMoreInformation.Value;
myRow["displayOpportunity"] = cbxActive.Checked;



_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());


}

**************** END WORKS*******************

*****************FUNDING*********************

AND YET the following works fine using the same table for the title field:

form page:

<asp:TextBox ID="txtFundingTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>

.cs page:

protected void btnFundingUpdateOpportunity_Click(object sender, EventArgs e)
{
if (txtFundingDescription.Value.Trim() != "")
{
harvestAndUpdateFundingFields();
message.Visible = true;
Label74.Visible = false;
}
else
{
Label74.Visible = true;
}
}
private void harvestAndUpdateFundingFields()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtFundingTitle.Text;
myRow["fundingSource"] = txtFundingSource.Text;
myRow["fundingType"] = txtFundingType.Text;
myRow["amount"] = txtFundingAmount.Text;
myRow["numAwardsAvailable"] =
int.Parse(txtFundingNumAwardsAvailable.Text);
myRow["awardCeiling"] = txtFundingCeiling.Text;
myRow["awardFloor"] = txtFundingFloor.Text;
myRow["eligibility"] = txtFundingElgibility.Value;
myRow["deadline"] = txtFundingDeadline.Text;
myRow["description"] = txtFundingDescription.Value;
myRow["moreInformation"] = txtFundingMoreInfo.Value;
myRow["displayOpportunity"] = cbxActive.Checked;

_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());

}

************END FUNDING*********************

public void UpdateOppoutunity(DataSet updatedDs, string userID)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "UpdateOpportunity";
DbCommand UpdateCommand = db.GetStoredProcCommand(sqlCommand);

string modifiedDate = DateTime.Now.ToString();

string
username, dateAdded,
title, dateModified, modifiedBy,
fundingSource, fundingType, eligibility,
deadline, description, moreInformation,
position, jobType, company,
department, address, city,
state, zip, zip4, type,
contact, events, location,
topic, date, organization,
qualifications, compensation, edutactionType,
source, categories, nominationForm,
salaryLevel, amount, awardCeiling,
awardFloor, country;

bool displayOpportunity;

int
iD, opportunity_ID, numAwardsAvailable;

DataRow myRow = updatedDs.Tables[0].Rows[0];


string sNumAwards = "0";
if (myRow["numAwardsAvailable"].ToString() != string.Empty )
sNumAwards = myRow["numAwardsAvailable"].ToString();


iD = int.Parse (myRow["ID"].ToString());
opportunity_ID = int.Parse (myRow["Opportunity_ID"].ToString());
username = userID;
displayOpportunity =
Convert.ToBoolean(myRow["displayOpportunity"].ToString());
dateAdded = myRow["dateAdded"].ToString();
title = myRow["title"].ToString();
dateModified = modifiedDate;
modifiedBy = username;
fundingSource = myRow["fundingSource"].ToString();
fundingType = myRow["fundingType"].ToString();
try{
amount =
(Convert.ToDouble(myRow["amount"].ToString())).ToString();
}catch(Exception e){
amount = "0";
}
numAwardsAvailable = int.Parse (sNumAwards);
try{
awardCeiling =
(Convert.ToDouble(myRow["awardCeiling"].ToString())).ToString();
}
catch(Exception e){
awardCeiling = "0";
}
try{
awardFloor =
(Convert.ToDouble(myRow["awardFloor"].ToString())).ToString();
}catch(Exception e){
awardFloor = "0";
}
eligibility = myRow["eligibility"].ToString();
deadline = myRow["deadline"].ToString();
description = myRow["description"].ToString();
moreInformation = myRow["moreInformation"].ToString();
position = myRow["position"].ToString();
jobType = myRow["jobType"].ToString();
company = myRow["company"].ToString();
department = myRow["department"].ToString();
address = myRow["address"].ToString();
city = myRow["city"].ToString();
state = myRow["state"].ToString();
country = myRow["countryId"].ToString();
zip = myRow["zip"].ToString();
zip4 = myRow["zip4"].ToString();
type = myRow["type"].ToString();
contact = myRow["contact"].ToString();
events = myRow["event"].ToString();
location = myRow["location"].ToString();
topic = myRow["topic"].ToString();
date = myRow["date"].ToString();
organization = myRow["organization"].ToString();
qualifications = myRow["qualifications"].ToString();
compensation = myRow["compensation"].ToString();
edutactionType = myRow["edutactionType"].ToString();
source = myRow["source"].ToString();
categories = myRow["categories"].ToString();
nominationForm = myRow["nominationForm"].ToString();
salaryLevel = myRow["salaryLevel"].ToString();


db.AddInParameter(UpdateCommand, "ID", DbType.Int32, iD);
db.AddInParameter(UpdateCommand, "Opportunity_ID", DbType.Int32,
opportunity_ID);
db.AddInParameter(UpdateCommand, "userName", DbType.String, username);
db.AddInParameter(UpdateCommand, "displayOpportunity", DbType.Boolean,
displayOpportunity);
db.AddInParameter(UpdateCommand, "dateAdded", DbType.String, dateAdded);
db.AddInParameter(UpdateCommand, "title", DbType.String, title);
db.AddInParameter(UpdateCommand, "dateModified", DbType.String,
dateModified);
db.AddInParameter(UpdateCommand, "modifiedBy", DbType.String, modifiedBy);
db.AddInParameter(UpdateCommand, "fundingSource", DbType.String,
fundingSource);
db.AddInParameter(UpdateCommand, "fundingType", DbType.String,
fundingType);
db.AddInParameter(UpdateCommand, "amount", DbType.Currency, amount);
db.AddInParameter(UpdateCommand, "numAwardsAvailable", DbType.Int32,
numAwardsAvailable);
db.AddInParameter(UpdateCommand, "awardCeiling", DbType.Currency,
awardCeiling);
db.AddInParameter(UpdateCommand, "awardFloor", DbType.Currency,
awardFloor);
db.AddInParameter(UpdateCommand, "eligibility", DbType.String,
eligibility);
db.AddInParameter(UpdateCommand, "deadline", DbType.String, deadline);
db.AddInParameter(UpdateCommand, "description", DbType.String,
description);
db.AddInParameter(UpdateCommand, "moreInformation", DbType.String,
moreInformation);
db.AddInParameter(UpdateCommand, "position", DbType.String, position);
db.AddInParameter(UpdateCommand, "jobType", DbType.String, jobType);
db.AddInParameter(UpdateCommand, "company", DbType.String, company);
db.AddInParameter(UpdateCommand, "department", DbType.String, department);
db.AddInParameter(UpdateCommand, "address", DbType.String, address);
db.AddInParameter(UpdateCommand, "city", DbType.String, city);
db.AddInParameter(UpdateCommand, "state", DbType.String, state);
db.AddInParameter(UpdateCommand, "zip", DbType.String, zip);
db.AddInParameter(UpdateCommand, "zip4", DbType.String, zip4);
db.AddInParameter(UpdateCommand, "country", DbType.String, country);

db.AddInParameter(UpdateCommand, "type", DbType.String, type);
db.AddInParameter(UpdateCommand, "contact", DbType.String, contact);
db.AddInParameter(UpdateCommand, "event", DbType.String, events);
db.AddInParameter(UpdateCommand, "location", DbType.String, location);
db.AddInParameter(UpdateCommand, "topic", DbType.String, topic);
db.AddInParameter(UpdateCommand, "date", DbType.String, date);
db.AddInParameter(UpdateCommand, "organization", DbType.String,
organization);
db.AddInParameter(UpdateCommand, "qualifications", DbType.String,
qualifications);
db.AddInParameter(UpdateCommand, "compensation", DbType.String,
compensation);
db.AddInParameter(UpdateCommand, "edutactionType", DbType.String,
edutactionType);
db.AddInParameter(UpdateCommand, "source", DbType.String, source);
db.AddInParameter(UpdateCommand, "categories", DbType.String, categories);
db.AddInParameter(UpdateCommand, "nominationForm", DbType.String,
nominationForm);
db.AddInParameter(UpdateCommand, "salaryLevel", DbType.String,
salaryLevel);


db.ExecuteNonQuery(UpdateCommand);

}

****************************************

What am I missing? I've been staring at this all day and am ready to tear my
hair out. Could it possibly be something server side? Help! Please!

Thanks,
Mickey
 
M

Mickey

Thanks for your response!

Yes, SQL Server.

Ack! Stored procedure. Didn't check that. I don't have access to view the
stored procedures but by the names of them it looks like the same stored
procedure is being used for updates on both forms. Is it still possible
that the store procedure could be the problem?

I'll forward this to the database guy as I have no clue about the Profiler.
Not that database savvy.

Thanks,
Mickey


Hans Kesting said:
After serious thinking Mickey wrote :
I've got some very simple code inserting data into a database. I have
been through it and through it probably a hundred times today. There is
one field that is not being updated in the database. I am as sure as I
can get that the code is correct. The same code is being used elsewhere
and works fine.

The txtWorksTitle is not being inserted into the "title" field, although
the txtFundingTitle is being inserted into the database and it uses the
exact same code and database field. See WORKS and FUNDING blocks below.
All other fields are fine. The database field is correct and the form
field is correct.

What database do you use?
If it is SqlServer, try the Profiler to see if that "title" is sent to the
database.
If not, the problem is in the code here.
If the title *is* sent to the database (as I suspect), the problem is in
your stored procedure (that you didn't show).

Hans Kesting

****************WORKS*******************
from the form page:

<asp:TextBox ID="txtWorksTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>
<asp:Button ID="btnWorksSaveOpportunity" runat="server"
OnClick="btnWorksUpdateOpportunity_Click"
Text="Save Opportunity" Width="110px" />


.cs page:

protected void btnWorksUpdateOpportunity_Click(object sender, EventArgs
e)
{
if (txtWorksDescription.Value.Trim() != "")
{
Works_HarvestAndUpdateValues();
message3.Visible = true;
Label71.Visible = false;
}
else
{
Label71.Visible = true;
}
}
private void Works_HarvestAndUpdateValues()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtWorksTitle.Text;
myRow["type"] = cboWorksType.SelectedValue.ToString();
myRow["deadline"] = txtWorksDeadline.Text;
myRow["contact"] = txtWorksContact.Text;
myRow["description"] = txtWorksDescription.Value;
myRow["moreInformation"] = txtWorksMoreInformation.Value;
myRow["displayOpportunity"] = cbxActive.Checked;



_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());


}

**************** END WORKS*******************

*****************FUNDING*********************

AND YET the following works fine using the same table for the title
field:

form page:

<asp:TextBox ID="txtFundingTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>

.cs page:

protected void btnFundingUpdateOpportunity_Click(object sender, EventArgs
e)
{
if (txtFundingDescription.Value.Trim() != "")
{
harvestAndUpdateFundingFields();
message.Visible = true;
Label74.Visible = false;
}
else
{
Label74.Visible = true;
}
}
private void harvestAndUpdateFundingFields()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtFundingTitle.Text;
myRow["fundingSource"] = txtFundingSource.Text;
myRow["fundingType"] = txtFundingType.Text;
myRow["amount"] = txtFundingAmount.Text;
myRow["numAwardsAvailable"] =
int.Parse(txtFundingNumAwardsAvailable.Text);
myRow["awardCeiling"] = txtFundingCeiling.Text;
myRow["awardFloor"] = txtFundingFloor.Text;
myRow["eligibility"] = txtFundingElgibility.Value;
myRow["deadline"] = txtFundingDeadline.Text;
myRow["description"] = txtFundingDescription.Value;
myRow["moreInformation"] = txtFundingMoreInfo.Value;
myRow["displayOpportunity"] = cbxActive.Checked;

_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());

}

************END FUNDING*********************

public void UpdateOppoutunity(DataSet updatedDs, string userID)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "UpdateOpportunity";
DbCommand UpdateCommand = db.GetStoredProcCommand(sqlCommand);

string modifiedDate = DateTime.Now.ToString();

string
username, dateAdded,
title, dateModified, modifiedBy,
fundingSource, fundingType, eligibility,
deadline, description, moreInformation,
position, jobType, company,
department, address, city,
state, zip, zip4, type,
contact, events, location,
topic, date, organization,
qualifications, compensation, edutactionType,
source, categories, nominationForm,
salaryLevel, amount, awardCeiling,
awardFloor, country;

bool displayOpportunity;

int
iD, opportunity_ID, numAwardsAvailable;

DataRow myRow = updatedDs.Tables[0].Rows[0];


string sNumAwards = "0";
if (myRow["numAwardsAvailable"].ToString() != string.Empty )
sNumAwards = myRow["numAwardsAvailable"].ToString();


iD = int.Parse (myRow["ID"].ToString());
opportunity_ID = int.Parse (myRow["Opportunity_ID"].ToString());
username = userID;
displayOpportunity =
Convert.ToBoolean(myRow["displayOpportunity"].ToString());
dateAdded = myRow["dateAdded"].ToString();
title = myRow["title"].ToString();
dateModified = modifiedDate;
modifiedBy = username;
fundingSource = myRow["fundingSource"].ToString();
fundingType = myRow["fundingType"].ToString();
try{
amount =
(Convert.ToDouble(myRow["amount"].ToString())).ToString();
}catch(Exception e){
amount = "0";
}
numAwardsAvailable = int.Parse (sNumAwards);
try{
awardCeiling =
(Convert.ToDouble(myRow["awardCeiling"].ToString())).ToString();
}
catch(Exception e){
awardCeiling = "0";
}
try{
awardFloor =
(Convert.ToDouble(myRow["awardFloor"].ToString())).ToString();
}catch(Exception e){
awardFloor = "0";
}
eligibility = myRow["eligibility"].ToString();
deadline = myRow["deadline"].ToString();
description = myRow["description"].ToString();
moreInformation = myRow["moreInformation"].ToString();
position = myRow["position"].ToString();
jobType = myRow["jobType"].ToString();
company = myRow["company"].ToString();
department = myRow["department"].ToString();
address = myRow["address"].ToString();
city = myRow["city"].ToString();
state = myRow["state"].ToString();
country = myRow["countryId"].ToString();
zip = myRow["zip"].ToString();
zip4 = myRow["zip4"].ToString();
type = myRow["type"].ToString();
contact = myRow["contact"].ToString();
events = myRow["event"].ToString();
location = myRow["location"].ToString();
topic = myRow["topic"].ToString();
date = myRow["date"].ToString();
organization = myRow["organization"].ToString();
qualifications = myRow["qualifications"].ToString();
compensation = myRow["compensation"].ToString();
edutactionType = myRow["edutactionType"].ToString();
source = myRow["source"].ToString();
categories = myRow["categories"].ToString();
nominationForm = myRow["nominationForm"].ToString();
salaryLevel = myRow["salaryLevel"].ToString();


db.AddInParameter(UpdateCommand, "ID", DbType.Int32, iD);
db.AddInParameter(UpdateCommand, "Opportunity_ID", DbType.Int32,
opportunity_ID);
db.AddInParameter(UpdateCommand, "userName", DbType.String, username);
db.AddInParameter(UpdateCommand, "displayOpportunity", DbType.Boolean,
displayOpportunity);
db.AddInParameter(UpdateCommand, "dateAdded", DbType.String,
dateAdded);
db.AddInParameter(UpdateCommand, "title", DbType.String, title);
db.AddInParameter(UpdateCommand, "dateModified", DbType.String,
dateModified);
db.AddInParameter(UpdateCommand, "modifiedBy", DbType.String,
modifiedBy);
db.AddInParameter(UpdateCommand, "fundingSource", DbType.String,
fundingSource);
db.AddInParameter(UpdateCommand, "fundingType", DbType.String,
fundingType);
db.AddInParameter(UpdateCommand, "amount", DbType.Currency, amount);
db.AddInParameter(UpdateCommand, "numAwardsAvailable", DbType.Int32,
numAwardsAvailable);
db.AddInParameter(UpdateCommand, "awardCeiling",
DbType.Currency, awardCeiling);
db.AddInParameter(UpdateCommand, "awardFloor",
DbType.Currency, awardFloor);
db.AddInParameter(UpdateCommand, "eligibility", DbType.String,
eligibility);
db.AddInParameter(UpdateCommand, "deadline", DbType.String, deadline);
db.AddInParameter(UpdateCommand, "description", DbType.String,
description);
db.AddInParameter(UpdateCommand, "moreInformation", DbType.String,
moreInformation);
db.AddInParameter(UpdateCommand, "position", DbType.String, position);
db.AddInParameter(UpdateCommand, "jobType", DbType.String, jobType);
db.AddInParameter(UpdateCommand, "company", DbType.String, company);
db.AddInParameter(UpdateCommand, "department", DbType.String,
department);
db.AddInParameter(UpdateCommand, "address", DbType.String, address);
db.AddInParameter(UpdateCommand, "city", DbType.String, city);
db.AddInParameter(UpdateCommand, "state", DbType.String, state);
db.AddInParameter(UpdateCommand, "zip", DbType.String, zip);
db.AddInParameter(UpdateCommand, "zip4", DbType.String, zip4);
db.AddInParameter(UpdateCommand, "country", DbType.String, country);

db.AddInParameter(UpdateCommand, "type", DbType.String, type);
db.AddInParameter(UpdateCommand, "contact", DbType.String, contact);
db.AddInParameter(UpdateCommand, "event", DbType.String, events);
db.AddInParameter(UpdateCommand, "location", DbType.String, location);
db.AddInParameter(UpdateCommand, "topic", DbType.String, topic);
db.AddInParameter(UpdateCommand, "date", DbType.String, date);
db.AddInParameter(UpdateCommand, "organization", DbType.String,
organization);
db.AddInParameter(UpdateCommand, "qualifications", DbType.String,
qualifications);
db.AddInParameter(UpdateCommand, "compensation", DbType.String,
compensation);
db.AddInParameter(UpdateCommand, "edutactionType", DbType.String,
edutactionType);
db.AddInParameter(UpdateCommand, "source", DbType.String, source);
db.AddInParameter(UpdateCommand, "categories", DbType.String,
categories);
db.AddInParameter(UpdateCommand, "nominationForm", DbType.String,
nominationForm);
db.AddInParameter(UpdateCommand, "salaryLevel", DbType.String,
salaryLevel);


db.ExecuteNonQuery(UpdateCommand);

}

****************************************

What am I missing? I've been staring at this all day and am ready to
tear my hair out. Could it possibly be something server side? Help!
Please!

Thanks,
Mickey
 
M

Mickey

The problem was in the stored procedure as you suggested. Thanks!!!!!!!

Mickey


Hans Kesting said:
After serious thinking Mickey wrote :
I've got some very simple code inserting data into a database. I have
been through it and through it probably a hundred times today. There is
one field that is not being updated in the database. I am as sure as I
can get that the code is correct. The same code is being used elsewhere
and works fine.

The txtWorksTitle is not being inserted into the "title" field, although
the txtFundingTitle is being inserted into the database and it uses the
exact same code and database field. See WORKS and FUNDING blocks below.
All other fields are fine. The database field is correct and the form
field is correct.

What database do you use?
If it is SqlServer, try the Profiler to see if that "title" is sent to the
database.
If not, the problem is in the code here.
If the title *is* sent to the database (as I suspect), the problem is in
your stored procedure (that you didn't show).

Hans Kesting

****************WORKS*******************
from the form page:

<asp:TextBox ID="txtWorksTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>
<asp:Button ID="btnWorksSaveOpportunity" runat="server"
OnClick="btnWorksUpdateOpportunity_Click"
Text="Save Opportunity" Width="110px" />


.cs page:

protected void btnWorksUpdateOpportunity_Click(object sender, EventArgs
e)
{
if (txtWorksDescription.Value.Trim() != "")
{
Works_HarvestAndUpdateValues();
message3.Visible = true;
Label71.Visible = false;
}
else
{
Label71.Visible = true;
}
}
private void Works_HarvestAndUpdateValues()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtWorksTitle.Text;
myRow["type"] = cboWorksType.SelectedValue.ToString();
myRow["deadline"] = txtWorksDeadline.Text;
myRow["contact"] = txtWorksContact.Text;
myRow["description"] = txtWorksDescription.Value;
myRow["moreInformation"] = txtWorksMoreInformation.Value;
myRow["displayOpportunity"] = cbxActive.Checked;



_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());


}

**************** END WORKS*******************

*****************FUNDING*********************

AND YET the following works fine using the same table for the title
field:

form page:

<asp:TextBox ID="txtFundingTitle" runat="server" CssClass="formFields"
Width="300px"></asp:TextBox>

.cs page:

protected void btnFundingUpdateOpportunity_Click(object sender, EventArgs
e)
{
if (txtFundingDescription.Value.Trim() != "")
{
harvestAndUpdateFundingFields();
message.Visible = true;
Label74.Visible = false;
}
else
{
Label74.Visible = true;
}
}
private void harvestAndUpdateFundingFields()
{
DataSet myDS = (DataSet)Session["selectedOpportunityDS"];
DataRow myRow = myDS.Tables[0].Rows[0];

myRow["title"] = txtFundingTitle.Text;
myRow["fundingSource"] = txtFundingSource.Text;
myRow["fundingType"] = txtFundingType.Text;
myRow["amount"] = txtFundingAmount.Text;
myRow["numAwardsAvailable"] =
int.Parse(txtFundingNumAwardsAvailable.Text);
myRow["awardCeiling"] = txtFundingCeiling.Text;
myRow["awardFloor"] = txtFundingFloor.Text;
myRow["eligibility"] = txtFundingElgibility.Value;
myRow["deadline"] = txtFundingDeadline.Text;
myRow["description"] = txtFundingDescription.Value;
myRow["moreInformation"] = txtFundingMoreInfo.Value;
myRow["displayOpportunity"] = cbxActive.Checked;

_dataResOpps.UpdateOppoutunity(myDS,
Session["userid"].ToString());

}

************END FUNDING*********************

public void UpdateOppoutunity(DataSet updatedDs, string userID)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "UpdateOpportunity";
DbCommand UpdateCommand = db.GetStoredProcCommand(sqlCommand);

string modifiedDate = DateTime.Now.ToString();

string
username, dateAdded,
title, dateModified, modifiedBy,
fundingSource, fundingType, eligibility,
deadline, description, moreInformation,
position, jobType, company,
department, address, city,
state, zip, zip4, type,
contact, events, location,
topic, date, organization,
qualifications, compensation, edutactionType,
source, categories, nominationForm,
salaryLevel, amount, awardCeiling,
awardFloor, country;

bool displayOpportunity;

int
iD, opportunity_ID, numAwardsAvailable;

DataRow myRow = updatedDs.Tables[0].Rows[0];


string sNumAwards = "0";
if (myRow["numAwardsAvailable"].ToString() != string.Empty )
sNumAwards = myRow["numAwardsAvailable"].ToString();


iD = int.Parse (myRow["ID"].ToString());
opportunity_ID = int.Parse (myRow["Opportunity_ID"].ToString());
username = userID;
displayOpportunity =
Convert.ToBoolean(myRow["displayOpportunity"].ToString());
dateAdded = myRow["dateAdded"].ToString();
title = myRow["title"].ToString();
dateModified = modifiedDate;
modifiedBy = username;
fundingSource = myRow["fundingSource"].ToString();
fundingType = myRow["fundingType"].ToString();
try{
amount =
(Convert.ToDouble(myRow["amount"].ToString())).ToString();
}catch(Exception e){
amount = "0";
}
numAwardsAvailable = int.Parse (sNumAwards);
try{
awardCeiling =
(Convert.ToDouble(myRow["awardCeiling"].ToString())).ToString();
}
catch(Exception e){
awardCeiling = "0";
}
try{
awardFloor =
(Convert.ToDouble(myRow["awardFloor"].ToString())).ToString();
}catch(Exception e){
awardFloor = "0";
}
eligibility = myRow["eligibility"].ToString();
deadline = myRow["deadline"].ToString();
description = myRow["description"].ToString();
moreInformation = myRow["moreInformation"].ToString();
position = myRow["position"].ToString();
jobType = myRow["jobType"].ToString();
company = myRow["company"].ToString();
department = myRow["department"].ToString();
address = myRow["address"].ToString();
city = myRow["city"].ToString();
state = myRow["state"].ToString();
country = myRow["countryId"].ToString();
zip = myRow["zip"].ToString();
zip4 = myRow["zip4"].ToString();
type = myRow["type"].ToString();
contact = myRow["contact"].ToString();
events = myRow["event"].ToString();
location = myRow["location"].ToString();
topic = myRow["topic"].ToString();
date = myRow["date"].ToString();
organization = myRow["organization"].ToString();
qualifications = myRow["qualifications"].ToString();
compensation = myRow["compensation"].ToString();
edutactionType = myRow["edutactionType"].ToString();
source = myRow["source"].ToString();
categories = myRow["categories"].ToString();
nominationForm = myRow["nominationForm"].ToString();
salaryLevel = myRow["salaryLevel"].ToString();


db.AddInParameter(UpdateCommand, "ID", DbType.Int32, iD);
db.AddInParameter(UpdateCommand, "Opportunity_ID", DbType.Int32,
opportunity_ID);
db.AddInParameter(UpdateCommand, "userName", DbType.String, username);
db.AddInParameter(UpdateCommand, "displayOpportunity", DbType.Boolean,
displayOpportunity);
db.AddInParameter(UpdateCommand, "dateAdded", DbType.String,
dateAdded);
db.AddInParameter(UpdateCommand, "title", DbType.String, title);
db.AddInParameter(UpdateCommand, "dateModified", DbType.String,
dateModified);
db.AddInParameter(UpdateCommand, "modifiedBy", DbType.String,
modifiedBy);
db.AddInParameter(UpdateCommand, "fundingSource", DbType.String,
fundingSource);
db.AddInParameter(UpdateCommand, "fundingType", DbType.String,
fundingType);
db.AddInParameter(UpdateCommand, "amount", DbType.Currency, amount);
db.AddInParameter(UpdateCommand, "numAwardsAvailable", DbType.Int32,
numAwardsAvailable);
db.AddInParameter(UpdateCommand, "awardCeiling",
DbType.Currency, awardCeiling);
db.AddInParameter(UpdateCommand, "awardFloor",
DbType.Currency, awardFloor);
db.AddInParameter(UpdateCommand, "eligibility", DbType.String,
eligibility);
db.AddInParameter(UpdateCommand, "deadline", DbType.String, deadline);
db.AddInParameter(UpdateCommand, "description", DbType.String,
description);
db.AddInParameter(UpdateCommand, "moreInformation", DbType.String,
moreInformation);
db.AddInParameter(UpdateCommand, "position", DbType.String, position);
db.AddInParameter(UpdateCommand, "jobType", DbType.String, jobType);
db.AddInParameter(UpdateCommand, "company", DbType.String, company);
db.AddInParameter(UpdateCommand, "department", DbType.String,
department);
db.AddInParameter(UpdateCommand, "address", DbType.String, address);
db.AddInParameter(UpdateCommand, "city", DbType.String, city);
db.AddInParameter(UpdateCommand, "state", DbType.String, state);
db.AddInParameter(UpdateCommand, "zip", DbType.String, zip);
db.AddInParameter(UpdateCommand, "zip4", DbType.String, zip4);
db.AddInParameter(UpdateCommand, "country", DbType.String, country);

db.AddInParameter(UpdateCommand, "type", DbType.String, type);
db.AddInParameter(UpdateCommand, "contact", DbType.String, contact);
db.AddInParameter(UpdateCommand, "event", DbType.String, events);
db.AddInParameter(UpdateCommand, "location", DbType.String, location);
db.AddInParameter(UpdateCommand, "topic", DbType.String, topic);
db.AddInParameter(UpdateCommand, "date", DbType.String, date);
db.AddInParameter(UpdateCommand, "organization", DbType.String,
organization);
db.AddInParameter(UpdateCommand, "qualifications", DbType.String,
qualifications);
db.AddInParameter(UpdateCommand, "compensation", DbType.String,
compensation);
db.AddInParameter(UpdateCommand, "edutactionType", DbType.String,
edutactionType);
db.AddInParameter(UpdateCommand, "source", DbType.String, source);
db.AddInParameter(UpdateCommand, "categories", DbType.String,
categories);
db.AddInParameter(UpdateCommand, "nominationForm", DbType.String,
nominationForm);
db.AddInParameter(UpdateCommand, "salaryLevel", DbType.String,
salaryLevel);


db.ExecuteNonQuery(UpdateCommand);

}

****************************************

What am I missing? I've been staring at this all day and am ready to
tear my hair out. Could it possibly be something server side? Help!
Please!

Thanks,
Mickey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top