Date field Data Type Mismatch error

I have exhausted all of my references and cannot find a solution to this anywhere.  I have a table in an Access db on my server (tblTemp).  I've created an .aspx page with a text box for the users to enter a date like 4/1/2007.  All of my other text fields post to my table perfectly, number and text fields, but when I enter a date in I get a "Data Type Mismatch" error.

I have two books on asp.net and neither one of them address date fields and have been unable to find anything on the web so it must be something either incredibly easy that it doesn't need to be mentioned or it's impossible to do.  Does anyone have any tips on how to format my date field to get it to match my db table?  The field in my db table is set to Date/Time. Don't know if this will help, but here is the code I am using.

 Thanks for any help with this,

Toni 

Cut-in Date:

<asp:TextBox ID="txtCutIn" runat="server"> </asp:TextBox>

Sub

SubmitProject(ByVal s As Object, ByVal e As EventArgs)

objCmd =

New Data.OleDb.OleDbCommand("INSERT INTO tblTemp (owner, manager, projtype, pf, status, category, subtype, product, conf, cutinmonth, cutinyr, currentprice, newprice, volume, cutindate) VALUES (@owner,@manager,@projtype,@pf,@status, @category,@subtype,@product,@conf, @cutinmonth, @cutinyr, @currentprice, @newprice, @volume, @cutin)", objConn)

 

objCmd.Parameters.AddWithValue(

"@owner", ddlOwner.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@manager", ddlMgr.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@projtype", ddlProjType.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@pf", ddlPF.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@status", ddlStatus.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@category", ddlCategory.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@subtype", ddlSubtype.SelectedItem.Value)

 

 

If ddlColor.SelectedIndex >= 1 Then

objCmd.Parameters.AddWithValue(

"@product", ddlColor.SelectedItem.Value)

End If

If ddlMono.SelectedIndex >= 1 Then

objCmd.Parameters.AddWithValue(

"@product", ddlMono.SelectedItem.Value)

End If

If ddlColorMFP.SelectedIndex >= 1 Then

objCmd.Parameters.AddWithValue(

"@product", ddlColorMFP.SelectedItem.Value)

End If

If ddlMonoMFP.SelectedIndex >= 1 Then

objCmd.Parameters.AddWithValue(

"@product", ddlMonoMFP.SelectedItem.Value)

End If

 

objCmd.Parameters.AddWithValue(

"@conf", ddlConf.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@cutinmonth", ddlCutInMonth.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@cutinyr", ddlCutInYr.SelectedItem.Value)

objCmd.Parameters.AddWithValue(

"@currentprice", txtCurrentPrice.Text)

objCmd.Parameters.AddWithValue(

"@newprice", txtNewPrice.Text)

objCmd.Parameters.AddWithValue(

"@red", txtRed.Text)

objCmd.Parameters.AddWithValue(

"@volume", txtVol.Text)

objCmd.Parameters.AddWithValue(

"@cutin", txtCutIn.Text)

 

 

 

objConn.Close()

objConn.Open()

objCmd.ExecuteNonQuery()

objConn.Close()

Response.Redirect(

"Default2.aspx")

End Sub 

 

 

0
thart
4/11/2007 10:41:34 PM
asp.net.web-forms 93655 articles. 4 followers. Follow

2 Replies
763 Views

Similar Articles

[PageSpeed] 21

You are passing a string variable when the database is expecting a date type.. So change the

objCmd.Parameters.AddWithValue("@cutin", txtCutIn.Text)

to

objCmd.Parameters.AddWithValue("@cutin", Convert.ToDateTime( txtCutIn.Text) )


Kumar Reddi
0
Kumar
4/11/2007 11:53:47 PM

That's exactlty what I needed - thank you so much! 

 

Toni

 

0
thart
4/12/2007 6:37:00 PM
Reply:

Similar Artilces:

data type mismatch error unvolving the date
using dreamwever on a asp page i keep on getting the annoying error when ever i do querys invloving dates getting the information from the access database Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E07) [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. /staff/WNC_CIS/Student_Attendance/SeatBooking/booked.asp, line 65 it seems to do this even if i write a date into the code apposed to getting it from a form <% Dim Rs_Daycheck__MMColParam Rs_Daycheck__MMColParam = "1" If (Request.QueryString("...

After adding a date field in a web form update gives error
Hi I have a web form which is a part of asp.net application. This process updates a row of a table. This works fine. However, I needed to update a DueDate field. So I added the DueDate field in the form and changed the stored procedure and the corresponding code in asp.net. Now the update does not work. I am getting the following error message: @poduedate is not a parameter for procedure prr_out_projsearch_update1.  The following is the code for stored procedure: alter proc prr_out_projsearch_update1 @prr_id int,@changes_required bit,@NeedUpdate bit = 1,@datecompleted datetime ...

"Data type mismatch in criteria expression" error when entering a date
I am having a very infuriating problem when trying to write dates to an access database.Everythime i try and add a new record I get this error back: "Data type mismatch in criteria expression." I am inputting the data correctly, the correct date format for the access fields etc but it doesnt like it. This is my code:    <%   Dim StartDate, EndDate, DepositAmount, DailyRate, data_source, con, sql_insert   Function ChkString(string)   If string = "" Then string = " "   ChkString = Replace(string, ...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

Why does it not let me type data in my database fields and gives me error "No row was updated, the data in row 1 was not committed?
Hi, I'm typing example records in my database fields for username, last name, firstname, city, state, etc directly into the database field but when I try to save it it says:  No row was updated. The data in row 1 was not committed.Error Source: .NetSqlClient Data Provider.Error Message: String or binary data would be truncated.The statement has been terminated.Correct the errors and retry or press ESC to cancel the change(s) Basically I'm just typing data into the fields but it won't allow me to save them.    The data types are all saved as...

Submitting Web forms fields to sql database by clicking on SUBMIT FORM and sending the form fields to email box
I have a created or designed a form to be stored in a SQL database table and at the same time when a user clicks on SUBMIT button the form fields will automatically goto the visitor email address immediately. Also i have created a database with tables for each of this forms Pls help i have over 10 forms designed but the problem of submitting them to the table database and the user email address is the challenge now.... You ned to familiarise yourself with the basics of database access in ASP.NET.  There are free tutuorials here: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/da...

Submitting data from a know web form to unknown web form
hi i m making a software in which i will submitt some data from a web page that will go to a web form of which contrlos are unknown to me only i know the name and how many controls in that form it means i can see the form only. how can i do this please help me soon with code plz its very argent.i m doin this wit the help of foxtrot.xray.WebRobot but its giving me error that this dll file is already exists in The file ('C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\_foxtrot.xray.WebRobot.dll' already exists).i don know what will do so please help me soon please thanks praveen We ca...

Update a Tablefield with Concatenating 4 fields
Hi,Within the vb-script from an ASP.NET webpage i'm trying to update an sqltable. I want to update a particular tablefield. Using the String as below:The field docpad (important to now) is a VARCHAR field with length 250. After executing the code i become an error: Syntax error converting the varchar value '~/Uploadmap/' to a column of data type int.I do not understaend this error because the targetfield is type VARCHAR and not int.   This is the code i'm using. What is it what i'm doing wrong?  sql2.Append("UPDATE dbo.T_20001_Documenten SET docpad = &...

.Net Date Data Type Formats
Gentlemen, I am trying to convert an applicaitons Date type fields from 12 hour time formats to ZULU or GMT time for a military application. I am using SQL Server 2005 and VB.Net with multiple versions of the .Net framework The first applicaiotn I went to convert is a older 1.1 VS 2003 app. I started by first changing my international and time settings on my box to 24 hundred military time format. At the writing of this article my clock show 14:13 as the time on the start menus toolbar, so that worked. I went into SQL server 2005 and all the Date-Time data fields comes back as Military time....

Open web page in IE and populate fields on the form from my web form
To the dot net Knights.  Many humble thanks in advance from a dot net surf. We have an vb application that opens multiple instances of IE object, each to different web pages.  It then takes information from the current record in the app, populates fields on each of the web pages, and them submits the forms.  We are then able to look at the resulting web pages and quickly get the info we're looking for.This prevents us from having to manually navigate to each web site, enter the same information and then wait for the page to open.  If there is ...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

synchronizing chunk of data of one web form for another web form
I'm making a web application. In one web form; i'm taking inputs from user. Now; there is some info given by user in this page which is needed for web form which is going to be displayed next. i want to display that info automatically on that web form so that user doesn't have to re-input that info in this next web form. Info from first page would be inserted into database when user clicks on the submit button. then that next web form would be displayed. and the chunk of info from previous page should be displayed there!!! how can i do this?? cany anybody help?? nobody can help me!! I...

superreview granted: [Bug 116346] Content-Type should be supplied for form data of 'enctype="multipart/ form-data"'[form sub]
Jonas Sicking <jonas@sicking.cc> has granted Boris Zbarsky <bzbarsky@mit.edu>'s request for superreview: Bug 116346: Content-Type should be supplied for form data of 'enctype="multipart/form-data"'[form sub] https://bugzilla.mozilla.org/show_bug.cgi?id=116346 Attachment 264215: Adds Content-Type with charset to each form-data part https://bugzilla.mozilla.org/attachment.cgi?id=264215&action=edit ...

superreview requested: [Bug 116346] Content-Type should be supplied for form data of 'enctype="multipart/ form-data"'[form sub]
Boris Zbarsky <bzbarsky@mit.edu> has asked Jonas Sicking <jonas@sicking.cc> for superreview: Bug 116346: Content-Type should be supplied for form data of 'enctype="multipart/form-data"'[form sub] https://bugzilla.mozilla.org/show_bug.cgi?id=116346 Attachment 264215: Adds Content-Type with charset to each form-data part https://bugzilla.mozilla.org/attachment.cgi?id=264215&action=edit ------- Additional Comments from Boris Zbarsky <bzbarsky@mit.edu> Looks good to me. sicking, would you sr? ...

Web resources about - Date field Data Type Mismatch error - asp.net.web-forms

Spatial mismatch - Wikipedia, the free encyclopedia
Spatial mismatch is the mismatch between where low-income households reside and where suitable job opportunities are available. In its original ...

Skills mismatch behind youth jobless: B20
Making graduates more attractive to employers is key to reducing youth unemployment, a conference heard today.

Retirement dreams a mismatch with savings reality
Australians have unrealistic expectations about the lifestyle they will be able to afford in retirement.

'Mismatch' now too close to call
'Mismatch' now too close to call

Newcastle Next: Powerful mismatch of architectural styles
WILL Newcastle be all that different from the Newcastle we see now, or the one 100 years ago?

Soccer mismatch
Dutch scientists claim that mistakes are inevitable when assistant referees are judging whether soccer players are offside or not. Raôul R. ...

Free to play iOS game marketing cost ‘mismatch is insane’
Free-to-play iOS game makers say the mismatch is “insane” between what it costs to acquire a new customer and how much revenue they’ll get through ...

Skills mismatch or ‘labour market failure’? Canada’s newcomer conundrum
In the past seven years, the number of people brought to Canada to do a job and then leave has eclipsed the number of people moving here annually ...

Labour Mismatch Canada: CIBC Report Warns Country's Standard Of Living At Risk
... workers languish in unemployment."We have people without jobs and jobs without people," said author and deputy economist Benjamin Tal.The mismatch ...

Mismatch
... itself. The company treats the stores as a sales channel but also as a communications channel with its customers. A complete and total mismatch. ...

Resources last updated: 12/18/2015 1:40:55 AM