Monday, December 17, 2007

What will happen if I save the data in different datatype?

What will happen if I save the data in different datatype?

This will cause an error when we use a different format of datatype.

For example:

The "price" data type is Currency. When you perform "Add" function by trying to add the word "One" to these fields, the system will not allow you to do it:

<%

Set conn = Server.CreateObject("Adodb.Connection")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

Set rs = Server.CreateObject("Adodb.Recordset")

rs.Open "Stock",conn,1,3

rs.addNew

rs.fields("ProductName") = "Music"

rs.fields("Price") = "One sen"

rs.update

rs.Close

Set rs = Nothing

%>

The error message as below will be shown:

So, please do not use a different or inappropriate format of "datatype".

No comments: