Can't update date in aspx to a MS-ACCESS table

两盒软妹~` 提交于 2019-12-25 09:40:53

问题


Hello I'm having problem with updating datatypes

I insert the date in the C# part like this

string strSQL = "INSERT into Frettir (CreatedBy,CreatedOn,Title,Description,Starts,Ends,CatId,SectionId,ArticleExt,Myndatexti,MyndUrAlbumi,NrMyndar) values(?,?,?,?,?,?,?,?,?,?,?,?)";

  cmd.Parameters.Add("@Starts",OleDbType.Date).Value = dstartdate;

but I update in the aspx part like this

UpdateCommand="UPDATE [Frettir] SET [Title]=@Title,[Description]=@Description,[CreatedBy]=@notandaID,[ArticleExt]=@ArticleExt, [Myndatexti]=@Myndatexti,[Starts]=@Starts WHERE [ArticleID]=@id2 "

 <UpdateParameters>
    <asp:Parameter Name="Title" Type="String" />
    <asp:Parameter Name="Description" Type="String" />
    <asp:Parameter Name="notandaID"  Type="int16" />
    <asp:Parameter Name="ArticleExt" Type="String" />
    <asp:Parameter Name="Myndatexti" Type="String" />
    <asp:Parameter Name="Starts" Type="DateTime" />
    <asp:QueryStringParameter Name="id2" QueryStringField="ArticleID" Type="Int32" />
</UpdateParameters>

I get an error Data type mismatch in criteria expression It seems that there are some type differences between the type that is input in the c# part and the aspx-part

Can anyone help me with this?


回答1:


I just did it once... I assigned the valued using the following code..

com.Parameters.AddWithValue("EmpDoj", EmpDoj.ToShortDateString());

It worked for me.. Thought it could help you as well...

Further, I'm eager to know the answer, why yours was not working...



来源:https://stackoverflow.com/questions/2653373/cant-update-date-in-aspx-to-a-ms-access-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!