I have the following to insert a new record:
<%
..
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=qqqqq;"
SQLStmt = "INSERT INTO tbl_qqqqqq (main_cat, cat_fee, fee_amount) "
SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "','" &
fee_amount & "')"
Set RS = Conn.Execute(SQLStmt)
set rs=nothing
..
%>
The "fee_amount" is a number value that has a default value associated
with that field in the Access DB.
When I submit the form WITHOUT a value in the "fee_amount" form field, I
get the following error:
"[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in
criteria expression."
That error typically means something like letters are are trying to be
inserted into a field that has a number data type.
In this case, no value has been given, when isn't the default value
being used when the INSERT statement is run?
Thanks.
Brett ba****@sprynet.com 6 2028
"BaWork" <ba****@sprynet.comwrote in message
news:ea**************@TK2MSFTNGP04.phx.gbl...
>I have the following to insert a new record:
<%
.
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=qqqqq;"
SQLStmt = "INSERT INTO tbl_qqqqqq (main_cat, cat_fee, fee_amount) "
SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "','" &
fee_amount & "')"
Set RS = Conn.Execute(SQLStmt)
set rs=nothing
.
%>
The "fee_amount" is a number value that has a default value associated
with that field in the Access DB.
When I submit the form WITHOUT a value in the "fee_amount" form field, I
get the following error:
"[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression."
That error typically means something like letters are are trying to be
inserted into a field that has a number data type.
In this case, no value has been given, when isn't the default value being
used when the INSERT statement is run?
Thanks.
Brett ba****@sprynet.com
You are passing a string in your SQL for the fee_amount. What is the
datatype for the fee_amount field in your db?
--
Mike Brind
You have quotes around it. So it thinks you are inserting an empty string
(or perhaps a space).
Numeric values shouldn't have quotes around them.
And since you are generating your string dynamically, maybe you could only
include that column conditionally (e.g. when there is a value).
A
"BaWork" <ba****@sprynet.comwrote in message
news:ea**************@TK2MSFTNGP04.phx.gbl...
>I have the following to insert a new record:
<%
.
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=qqqqq;"
SQLStmt = "INSERT INTO tbl_qqqqqq (main_cat, cat_fee, fee_amount) "
SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "','" &
fee_amount & "')"
Set RS = Conn.Execute(SQLStmt)
set rs=nothing
.
%>
The "fee_amount" is a number value that has a default value associated
with that field in the Access DB.
When I submit the form WITHOUT a value in the "fee_amount" form field, I
get the following error:
"[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression."
That error typically means something like letters are are trying to be
inserted into a field that has a number data type.
In this case, no value has been given, when isn't the default value being
used when the INSERT statement is run?
Thanks.
Brett ba****@sprynet.com
"Mike Brind" <us********@smap.comwrote in message
news:e8**************@TK2MSFTNGP02.phx.gbl...
"BaWork" <ba****@sprynet.comwrote in message
news:ea**************@TK2MSFTNGP04.phx.gbl...
>>I have the following to insert a new record:
<% .
Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DSN=qqqqq;" SQLStmt = "INSERT INTO tbl_qqqqqq (main_cat, cat_fee, fee_amount) " SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "','" & fee_amount & "')" Set RS = Conn.Execute(SQLStmt) set rs=nothing
. %>
The "fee_amount" is a number value that has a default value associated with that field in the Access DB.
When I submit the form WITHOUT a value in the "fee_amount" form field, I get the following error:
"[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression."
That error typically means something like letters are are trying to be inserted into a field that has a number data type.
In this case, no value has been given, when isn't the default value being used when the INSERT statement is run?
Thanks.
Brett ba****@sprynet.com
You are passing a string in your SQL for the fee_amount. What is the
datatype for the fee_amount field in your db?
--
Mike Brind
Oh, and other things you should be aware of:
1. Don't use a DSN to connect to Access. Use the OLEDB Provider. www.connectionstrings.com
2. Don't create a recordset to insert records http://www.aspfaq.com/show.asp?id=2191
3. Avoid messing around with delimiting values by using a saved queries
(which also helps protect against SQL injection) rather than dynamic SQL
statements. http://groups.google.com/group/micro...d322b882a604bd
--
Mike Brind
Are you saying it should be this:
SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "',' &
fee_amount & ')"
When I do that, I get a "[Microsoft][ODBC Microsoft Access Driver]
Syntax error in INSERT INTO statement." error message.
Thanks.
Brett
Aaron Bertrand [SQL Server MVP] wrote:
You have quotes around it. So it thinks you are inserting an empty string
(or perhaps a space).
Numeric values shouldn't have quotes around them.
And since you are generating your string dynamically, maybe you could only
include that column conditionally (e.g. when there is a value).
A
"BaWork" <ba****@sprynet.comwrote in message
news:ea**************@TK2MSFTNGP04.phx.gbl...
>>I have the following to insert a new record:
<% .
Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DSN=qqqqq;" SQLStmt = "INSERT INTO tbl_qqqqqq (main_cat, cat_fee, fee_amount) " SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "','" & fee_amount & "')" Set RS = Conn.Execute(SQLStmt) set rs=nothing
. %>
The "fee_amount" is a number value that has a default value associated with that field in the Access DB.
When I submit the form WITHOUT a value in the "fee_amount" form field, I get the following error:
"[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression."
That error typically means something like letters are are trying to be inserted into a field that has a number data type.
In this case, no value has been given, when isn't the default value being used when the INSERT statement is run?
Thanks.
Brett ba****@sprynet.com
Mike,
The data type is "number".
Thanks for the other information. I'll look into it later today.
Brett
Mike Brind wrote:
"Mike Brind" <us********@smap.comwrote in message
news:e8**************@TK2MSFTNGP02.phx.gbl...
>>"BaWork" <ba****@sprynet.comwrote in message news:ea**************@TK2MSFTNGP04.phx.gbl...
>>>I have the following to insert a new record:
<% .
Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DSN=qqqqq;" SQLStmt = "INSERT INTO tbl_qqqqqq (main_cat, cat_fee, fee_amount) " SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "','" & fee_amount & "')" Set RS = Conn.Execute(SQLStmt) set rs=nothing
. %>
The "fee_amount" is a number value that has a default value associated with that field in the Access DB.
When I submit the form WITHOUT a value in the "fee_amount" form field, I get the following error:
"[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression."
That error typically means something like letters are are trying to be inserted into a field that has a number data type.
In this case, no value has been given, when isn't the default value being used when the INSERT statement is run?
Thanks.
Brett ba****@sprynet.com
You are passing a string in your SQL for the fee_amount. What is the datatype for the fee_amount field in your db?
-- Mike Brind
Oh, and other things you should be aware of:
1. Don't use a DSN to connect to Access. Use the OLEDB Provider. www.connectionstrings.com
2. Don't create a recordset to insert records http://www.aspfaq.com/show.asp?id=2191
3. Avoid messing around with delimiting values by using a saved queries
(which also helps protect against SQL injection) rather than dynamic SQL
statements. http://groups.google.com/group/micro...d322b882a604bd
--
Mike Brind
Are you saying it should be this:
>
SQLStmt = SQLStmt & "VALUES ('" & main_cat & "','" & cat_fee & "',' &
fee_amount & ')"
No, I am saying:
SQLStmt & " SELECT '" & main_cat & "', '" & cat_fee & ", " & fee_amount
However, that dangling , will cause an error if fee_amount is empty.
A This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Philip Boonzaaier |
last post by:
I want to be able to generate SQL statements that will go through a list of
data, effectively row by row, enquire on the database if this exists in...
|
by: harborboy76 |
last post by:
Hi,
I am trying to insert a large number of rows into a table
inside a SPL. But every time, I run the SPL, the table is
locked because of the...
|
by: 73blazer |
last post by:
Hello,
I'm looking for a way to make some of my insert templates more readable
by placing comments in between the values. I cannot seem to find a...
|
by: kosta |
last post by:
hello! one of my forms communicates with a database, and is
supposed to add a row to a table using an Insert
statement... however, I get a 'oledb -...
|
by: Tim::.. |
last post by:
Can someone please tell me why I keep getting the following error from the
code below!
Error: INSERT statement conflicted with COLUMN FOREIGN KEY...
|
by: Metal Dave |
last post by:
I do not understand the error handling of SQL Server here. Any error in
bulk insert seems to halt the current T-SQL statement entirely, rendering...
|
by: Jack |
last post by:
Hi,
I am gathering the input values to a form using Request.form method from the
processing page. After all the data is captured, I am building sql...
|
by: mahajanvit |
last post by:
Hi one and all
I got this problem during my project. So in order to solve this I made
a very small application. I am trying to insert using SP and...
|
by: rn5a |
last post by:
During registration, users are supposed to enter the following
details: First Name, Last Name, EMail, UserName, Password, Confirm
Password,...
|
by: Maklar60 |
last post by:
I am attempting to execute an INSERT statement on my page but continually get the following error:
Microsoft OLE DB Provider for ODBC Drivers...
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
| |