ClickaNerd-WebHosting
New Member
I dont have much time so here is alot of code:<BR>void f_AddEmployee(object sender, EventArgs e)<BR> {<BR> if (Page.IsValid)<BR> {<BR> try<BR> {<BR> string strConnection = ConnectionString();<BR> OleDbConnection objConnection = new OleDbConnection(strConnection);<BR> <BR> string strAddEmployeeSQL = "SELECT * FROM OrgEmployee";<BR> DataSet objDataSet = new DataSet();<BR> OleDbDataAdapter objAdapter = new OleDbDataAdapter(strAddEmployeeSQL, objConnection);<BR> objAdapter.Fill(objDataSet, "OrgEmployee");<BR> <BR> DataTable objTable;<BR> DataRow objNewRow;<BR> <BR> objTable = objDataSet.Tables["OrgEmployee"];<BR> objNewRow = objTable.NewRow();<BR> objNewRow["FEID"] = Request.Cookies["PayOut"]["FEID"];<BR> objNewRow["SSN"] = Request.Form["SSN"];<BR> objNewRow["LName"] = Request.Form["LastName"];<BR> objNewRow["FName"] = Request.Form["FirstName"];<BR> objNewRow["MName"] = Request.Form["MiddleName"];<BR> objNewRow["EID"] = Request.Form["EmployeeID"];<BR> objNewRow["Dept"] = Request.Form["Department"];<BR> objNewRow["JobCode"] = Request.Form["JobClass"];<BR> objNewRow["Address1"] = Request.Form["Address"];<BR> objNewRow["Address2"] = Request.Form["Address2"];<BR> objNewRow["City"] = Request.Form["City"];<BR> objNewRow["ST"] = Request.Form["State"];<BR> objNewRow["Zip"] = Request.Form["Zip"];<BR> objNewRow["Country"] = Request.Form["Country"];<BR> objNewRow["HomePhone"] = Request.Form["HomePhone"];<BR> objNewRow["WorkPhone"] = Request.Form["WorkPhone"];<BR> objNewRow["Ext"] = Request.Form["WorkPhoneExt"];<BR> objNewRow["EMail"] = Request.Form["EMail"];<BR> objNewRow["Location"] = Request.Form["Location"];<BR> objNewRow["BirthDt"] = Convert.ToDateTime(Request.Form["DateofBirth"]);<BR> objNewRow["HireDt"] = Convert.ToDateTime(Request.Form["HireDate"]);<BR> objNewRow["AnnDt1"] = Convert.ToDateTime(Request.Form["AnniversaryDate1"]);<BR> objNewRow["AnnDt2"] = Convert.ToDateTime(Request.Form["AnniversaryDate2"]);<BR> objNewRow["AnnDt3"] = Convert.ToDateTime(Request.Form["AnniversaryDate3"]);<BR> objNewRow["AnnDt4"] = Convert.ToDateTime(Request.Form["AnniversaryDate4"]);<BR> objNewRow["AnnDt5"] = Convert.ToDateTime(Request.Form["AnniversaryDate5"]);<BR> objNewRow["TermDt"] = Convert.ToDateTime(Request.Form["TerminationDate"]);<BR> objNewRow["Vacation"] = Request.Form["VacationLeave"];<BR> objNewRow["Sick"] = Request.Form["SickLeave"];<BR> <BR> if (Request.Form["SalaryPer"] == "Year")<BR> {<BR> objNewRow["Salary"] = Convert.ToDecimal(Request.Form["Salary"]);<BR> objNewRow["PeriodRate"] = Convert.ToDecimal(0);<BR> objNewRow["HourRate"] = Convert.ToDecimal(Request.Form["Salary"]) / Convert.ToDecimal(2080);<BR> }<BR> else if (Request.Form["SalaryPer"] == "Period")<BR> {<BR> }<BR> else if (Request.Form["SalaryPer"] == "Hour")<BR> {<BR> }<BR> <BR> objNewRow["OTRate"] = Request.Form["OTRate"];<BR> objNewRow["PayFreq"] = Request.Form["PayFrequency"];<BR> objNewRow["MStat"] = Request.Form["MaritalStatus"];<BR> objNewRow["Deductions"] = Request.Form["ClaimedDeductions"];<BR> objNewRow["AddWH"] = Request.Form["Extrawithholding"];<BR> objNewRow["Route"] = Request.Form["RouteNumber"];<BR> objNewRow["Account"] = Request.Form["BankAccount"];<BR> objNewRow["SupvID"] = Request.Form["Supervisor"];<BR> objNewRow["Spouse"] = Request.Form["Spouse"];<BR> objNewRow["EmergContact"] = Request.Form["EmergencyContact"];<BR> objNewRow["EmergPhone"] = Request.Form["EmergencyPhone"];<BR> objNewRow["EmergExt"] = Request.Form["EmergencyPhoneExt"];<BR> objNewRow["UserID"] = Request.Form["UserName"];<BR> objNewRow["Password"] = Request.Form["Password1"];<BR> objNewRow["AddDt"] = DateTime.Now.ToString("d");<BR> objNewRow["UpdDt"] = DateTime.Now.ToString("d");<BR> objNewRow["UID"] = Request.Cookies["PayOut"]["FEID"];<BR> objTable.Rows.Add(objNewRow);<BR> <BR> OleDbCommandBuilder objBuilder = new OleDbCommandBuilder(objAdapter);<BR> objAdapter.UpdateCommand = objBuilder.GetUpdateCommand();<BR> objAdapter.InsertCommand = objBuilder.GetInsertCommand();<BR> objAdapter.DeleteCommand = objBuilder.GetDeleteCommand();<BR> objAdapter.Update(objDataSet, "OrgEmployee");<BR> <BR> Response.Redirect("OrgEmpRecords.asp?message=Employee Added");<BR> }<BR> catch(OleDbException objError)<BR> {<BR> PageErrors.Text = "<B>There are Errors on the page:</B>";<BR> PageErrors.Text += "<BR><B>Message:</B> " + objError.Message;<BR> PageErrors.Text += "<BR><B>Source:</B> " + objError.Source;<BR> PageErrors.Text += "<BR><B>InnerException:</B> " + objError.InnerException;<BR> PageErrors.Text += "<BR><B>ErrorCode:</B> " + objError.ErrorCode;<BR> PageErrors.Text += "<BR><B>Errors:</B> " + objError.Errors; <BR> }<BR> }<BR> }<BR><BR><BR><BR><BR>I get this error:<BR>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <BR><BR>Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.<BR><BR>Source Error: Line 167: objAdapter.Update(objDataSet, "OrgEmployee");<BR><BR>Someone please give me some guidence. I think it has to do with the values I am filling in the database. How do I convert a string to a currency in C#?Dean,<BR>I got the same type of error some time back. My code ran fine in the Beta release, but started getting the error when I switched to the SDK 1.0.<BR><BR>I finally traced it to a problem with the field names I was using in my database. I had a date field named (oddly enough) Date. The Beta overlooked this problem, but the 1.0 tripped over it.<BR><BR>I looked at your code and didn't see anything obvious, but .Net has so many language elements that it's possible there is some kind of reserved word burried in there.<BR><BR>You've probably been over your insert statement dozens of times without finding any violations (I did). <BR><BR>If possible, you might try quickly putting a single-letter prefix on each of your database fields and give it a try.<BR><BR>Do post the answer when you track it down. I'm sure it'll pop up again.<BR><BR>Tom T