Hi,
I have a MS Access table. One of the field's data types is set as 'Date/Time'. This cannot be changed.
I want to update this field based on a text box value. If the text box value = "" then I want to put this or nothing in the database.
I was looking at using nullables but ran into the error 'Data type mismatch in criteria expression.'
This is the code that I have been trying:
Any suggestion here will be greatly appreciated.
Thanks
I have a MS Access table. One of the field's data types is set as 'Date/Time'. This cannot be changed.
I want to update this field based on a text box value. If the text box value = "" then I want to put this or nothing in the database.
I was looking at using nullables but ran into the error 'Data type mismatch in criteria expression.'
This is the code that I have been trying:
VB.NET:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]Dim [FONT=Consolas][SIZE=2]date2 [/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]DateTime[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]?[/SIZE][/FONT][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]date2 = Nothing
[/SIZE][/FONT][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
Query = [FONT=Consolas][SIZE=2][COLOR=#a31515]"UPDATE tdata SET dob = '"[/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] & date2 & [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"' "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] + tcondition[/SIZE][/FONT][/SIZE][/FONT]
cmd = [COLOR=#0000ff]New[/COLOR][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]OleDbCommand[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2](Query, conn_tdata)[/SIZE][/FONT][/SIZE][/FONT]
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]cmd.ExecuteNonQuery()
[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]
Any suggestion here will be greatly appreciated.
Thanks